【发布时间】:2021-04-02 03:51:00
【问题描述】:
我的 IAM 帐户至少有“管理员”权限。据我所知,我可以在 Web 控制台中执行所有操作。例如,
最近我通过提供访问密钥、默认区域和输出格式下载了 aws-cli 和 quickly configured。然后我尝试发出一些命令,发现其中大部分(但不是全部)都有权限问题。例如
$ aws --version
aws-cli/1.16.243 Python/3.7.4 Windows/10 botocore/1.12.233
$ aws s3 ls s3://test-bucket
An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
$ aws ec2 describe-instances
An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation.
$ aws iam get-user
{
"User": {
"Path": "/",
"UserName": "xxx@xxx.xxx",
"UserId": "xxxxx",
"Arn": "arn:aws:iam::nnnnnnnnnn:user/xxx@xxx.xxx",
"CreateDate": "2019-08-21T17:09:25Z",
"PasswordLastUsed": "2019-09-21T16:11:34Z"
}
}
在我看来,使用访问密钥进行身份验证的 cli 与使用 MFA 进行身份验证的 Web 控制台具有不同的权限集。
为什么 CLI 和 GUI 之间的权限不一致?如何使其保持一致?
【问题讨论】:
-
你生成了私钥和公钥吗?您是否在尝试使用 aws cli 的机器上配置了它们?
-
@muasif80,cli 使用访问密钥而不是 RSA pri/pub 密钥。我有 RSA 密钥,但它们用于 ssh 到 ec2,而不是用于 cli authn。我还为 cli 生成了访问密钥。
-
使用 --debug 运行 cli 命令,您将看到它是如何进行身份验证的,并且基于此您可以查看您是否使用了正确的角色/用户等
-
@JamesDean,--debug 仅转储本地调用堆栈。拒绝发生在服务器端,因此无济于事。我从服务器得到的只是 403 响应代码和一些无意义的哈希代码在响应正文中使用 --debug。
标签: aws-cli