通过AWS CLI传递访问密钥和秘密密钥 [英] Passing in access and secret keys through AWS CLI
问题描述
由于某些企业限制,我只能通过命令行访问AWS,并且无法设置环境变量.我想知道是否有任何方式可以通过这种方式通过命令传递密钥:
Due to certain enterprise limitations, I'm only able to access AWS through the command line, and I cannot set environment variables. I was wondering if there is any way to pass in my keys with the command in a manner like this:
aws s3 cp <file> s3://testbucket --aws-access-key <accesskey> --aws-secret-key <secretkey>
我注意到这个问题相当相似,尽管它似乎答案可能不适用于我的情况,或者无法参考ec2din命令,因此我无法将其转换为将文件复制到s3.我只得到响应Unknown options: --aws-access-key,--aws-secret-key
.
I noticed that this question is fairly similar, although it seems that the answers are either not applicable to my situation or referencing the ec2din command, which I could not translate into copying files to s3. I just get the response Unknown options: --aws-access-key,--aws-secret-key
.
推荐答案
尝试一下:
AWS_ACCESS_KEY_ID=AAAA AWS_SECRET_ACCESS_KEY=BBB aws s3 cp <file> s3://testbucket
这将仅设置此命令的键.如果您需要会话密钥,请按如下所示导出它们:
This will set the keys for this command only. If you need the keys for the session, export them like below:
export AWS_ACCESS_KEY_ID=AAAA ; export AWS_SECRET_ACCESS_KEY=BBB ; aws s3 cp <file> s3://testbucket
这篇关于通过AWS CLI传递访问密钥和秘密密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!