Cloud SDK命令gsutil config -a

时间:2017-06-09 00:47:17

标签: docker kubernetes google-cloud-platform google-cloud-storage google-cloud-sdk

我试图在我的Dockerfile中包含我的Google存储空间的凭据,这样我每次创建新的Pod或Kubernetes中的其他模块时都不必这样做。 那么有没有办法把这个命令放在这个

 gsutil config -a (Access Key) (Secret)

而不是运行命令

 gsutil config -a

然后手动插入(访问密钥)和(密码)。

由于

1 个答案:

答案 0 :(得分:0)

您可以使用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?