2015-08-08 72 views
3

我想在Docker容器中使用gsutil。我已经创建了O2Auth服务帐户JSON文件。Google gsutil auth without prompt

如何设置gsutil auth以使用JSON配置文件并在不提示的情况下执行命令?

目前我得到的是这样的:

$ gsutil config -e 
It looks like you are trying to run "/.../google-cloud-sdk/bin/bootstrapping/gsutil.py config". 
The "config" command is no longer needed with the Cloud SDK. 
To authenticate, run: gcloud auth login 
Really run this command? (y/N) y 
This command will create a boto config file at /.../.boto 
containing your credentials, based on your responses to the following questions. 
What is the full path to your private key file? 

什么命令/参数/设置我必须使用情况的提示?

回答

6

通过执行解决了这个问题:

gcloud auth activate-service-account --key-file=/opt/gcloud/auth.json 

整个例如,完成集装箱可以在这里找到:blacklabelops/gcloud

0

如果只想GSUtil的并绕过提示您可以用希望做很容易脚本:

#!/usr/bin/expect 
spawn gsutil config -e 
expect "What is the full path to your private key file?" { send "/path/your.key\r" } 
expect "Would you like gsutil to change the file permissions for you? (y/N)" { send "y\r" } 
expect "What is your project-id?" { send "your-projet-42\r" } 
interact 
0

只使用gsutil会:

第一次运行这个命令来配置认证手动

gsutil config -a 

这将创建/root/.boto文件与所需的证书。 将该路径/文件复制到泊坞窗图像中。

gsutil现在将使用这些凭证。