我的AWS CLI不适用于sudo [英] My AWS CLI didn't work with sudo

查看:158
本文介绍了我的AWS CLI不适用于sudo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用aws cli的shell脚本,我的脚本将使用sudo(例如:sudo ./test.sh)

I have shell script that uses aws cli, my script will be executed with sudo (Ex: sudo ./test.sh)

但是我收到消息:Unable to locate credentials. You can configure credentials by running "aws configure".

实际上,我同时做了sudo aws configureaws configure

Actually, I did config for both sudo aws configure and aws configure

我做错了什么? 请帮忙. 谢谢!

What did I do wrong? Please help. Thanks!

推荐答案

您可能必须使用-E来运行sudo才能保留由aws cli设置的环境变量.
sudo -E ./test.sh

You might have to run sudo with -E to preserve the environment variables set by aws cli.
sudo -E ./test.sh

这篇关于我的AWS CLI不适用于sudo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆