2015-08-08 69 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現在將使用這些憑證。