[英]`An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.` w/`aws s3 ls`
I successfully authenticate with 2 factor but when using aws s3 ls
I keep getting我成功地通过 2 个因素进行了身份验证,但是在使用aws s3 ls
时,我不断得到
An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.调用 ListBuckets 操作时发生错误 (InvalidToken):提供的令牌格式不正确或无效。
And I do have admin rights.而且我确实有管理员权限。
Issue was that I wasn't passing the --region
in. eg aws s3 --region us-gov-west-1 ls
.问题是我没有传入--region
。例如aws s3 --region us-gov-west-1 ls
。 I suppose this could be set with an ENV variable too.我想这也可以用 ENV 变量设置。 That error message is a candidate for improvement.该错误消息是改进的候选者。
This error also occurs when aws cli
reads the aws_session_token
and aws_security_token
declared in the ~/.aws
file, which might be associated to a previously used account.当aws cli
读取~/.aws
文件中声明的aws_session_token
和aws_security_token
时,也会发生此错误,这可能与以前使用的帐户相关联。 Removing both and leaving just the key and the credentials associated to the account where the bucket is will force aws
to establish the connection.删除两者并只留下与存储桶所在帐户关联的密钥和凭据将强制aws
建立连接。
Please delete .aws/credentials file from your users account and reconfigure your aws cli.请从您的用户帐户中删除.aws/credentials文件并重新配置您的 aws cli。 If you already associated with another account then there are high chances of this type of error.如果您已经与另一个帐户相关联,那么发生此类错误的可能性很高。
Run aws configure运行 aws 配置
You may leave access key and access key id blank if you have an IAM role attached如果您附加了 IAM 角色,您可以将访问密钥和访问密钥 ID 留空
Set value for 'region'设置“区域”的值
Now you will be able to successfully run 'aws s3 ls'现在您将能够成功运行“aws s3 ls”
Else run 'aws s3 ls --region '否则运行'aws s3 ls --region'
在 .aws 凭据文件中删除会话令牌,它将起作用
If you are using AWS Single Sign-on you can pass --profile <profile_name>
and it should solve the issue如果您使用的是 AWS Single Sign-on,您可以传递--profile <profile_name>
它应该可以解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.