【问题标题】:Cloud SDK command gsutil config -aCloud SDK 命令 gsutil config -a
【发布时间】:2017-11-10 20:56:58
【问题描述】:
我正在尝试将我的 Google 存储凭据包含在我的 Dockerfile 中,这样我就不必每次在 Kubernetes 中创建新 Pod 或另一个死机时都这样做。
那么有没有办法像这样放置这个命令
gsutil config -a (Access Key) (Secret)
而不是运行命令
gsutil config -a
然后手动插入(访问密钥)和(秘密)。
谢谢
【问题讨论】:
标签:
docker
kubernetes
google-cloud-platform
google-cloud-storage
google-cloud-sdk
【解决方案1】:
您可以使用echo 传递输入并将其通过管道传递给gsutil。
请记住为什么 gsutil 命令不接受命令行参数 - 命令存储在 shell 的历史文件中,如果它们包含这些秘密作为命令行参数,很容易泄露您的秘密。
因此,以下命令将存储在 shell 历史记录中(除非您以其他方式阻止它)并且可能包含您的秘密。
$ echo -e "$ACCESS_KEY_ID\n$ACCESS_KEY_SECRET\n" | gsutil config -a
This command will configure HMAC credentials, but gsutil will use
OAuth2 credentials from the Cloud SDK by default. To make sure the
HMAC credentials are used, run: "gcloud config set
pass_credentials_to_gsutil false".
This command will create a boto config file at /Users/tuxdude/.boto
containing your credentials, based on your responses to the following
questions.
Boto config file "/Users/tuxdude/.boto" created. If you need to use a
proxy to access the Internet please see the instructions in that file.
What is your google access key ID? What is your google secret access key?