AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1127435
Accepted
Arrow Root
Arrow Root
Asked: 2023-03-29 23:24:30 +0800 CST2023-03-29 23:24:30 +0800 CST 2023-03-29 23:24:30 +0800 CST

跨账户 SSM 会话:AccessDeniedException

  • 772

我有两个 AWS 账户,每个账户中有一个角色:Account-A有RoleA和Account-B有RoleB。

RoleA 将假定 RoleB 能够通过 连接到 Account-B 中的 EC2 实例ssm start-session。

使用 RoleA,我能够承担 RoleB 并使用 aws cli 描述 Account-B 中的实例,但由于以下错误,我无法启动 ssm 会话:

An error occurred (AccessDeniedException) when calling the TerminateSession operation: User: arn:aws:sts::222222222222:assumed-role/RoleB/RoleB-SSM-test is not authorized to perform: ssm:TerminateSession on resource: arn:aws:ssm:us-east-1:222222222222:assumed-role/RoleB/RoleB-SSM-test-000000000000 because no identity-based policy allows the ssm:TerminateSession action

RoleA策略:

   {
       "Version": "2012-10-17",
       "Statement": [
           {
               "Effect": "Allow",
               "Action": [
                   "sts:AssumeRole"
               ],
               "Resource": [
                   "arn:aws:iam::222222222222:role/RoleB"
               ]
           }
       ]
   }

角色B政策:

   {
       "Version": "2012-10-17",
       "Statement": [
           {
               "Sid": "",
               "Effect": "Allow",
               "Action": [
                   "ssm:DescribeSessions",
                   "ssm:GetConnectionStatus",
                   "ssm:DescribeInstanceProperties",
                   "ec2:DescribeInstances",
                   "ssm:StartSession"
               ],
               "Resource": [
                   "arn:aws:ec2:us-east-1:222222222222:instance/i-123456abc789102de",
                   "arn:aws:ssm:us-east-1:222222222222:document/SSM-SessionManagerRunShell",
                   "arn:aws:ssm:us-east-1:222222222222:document/AWS-StartSSHSession"
               ]
           },
           {
               "Sid":"",
               "Effect":"Allow",
               "Action": [
                   "ssm:TerminateSession"
               ],
               "Resource": "*",
               "Condition": {
                   "StringLike": {
                       "ssm:resourceTag/aws:ssmmessages:session-id": [
                           "AROAXXXXXXXXXXXXX"
                       ]
                   }
               }
   
           }
       ]
   }

最初,ssm:TerminateSessionin RoleB 策略没有条件并且与其他操作并存,我进行了此更改以尝试解决此错误,但没有成功,出现相同的错误消息。

我做错了什么?

amazon-ec2
  • 1 1 个回答
  • 27 Views

1 个回答

  • Voted
  1. Best Answer
    palvarez
    2023-03-30T20:42:04+08:002023-03-30T20:42:04+08:00

    您的 RoleB 策略缺少某些权限。根据文档,您需要kms:GenerateDataKey加密会话数据,还需要访问 SSM 生成的文档。以下是文档中的示例策略:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ssm:StartSession"
                ],
                "Resource": [
                    "arn:aws:ec2:region:account-id:instance/instance-id",
                    "arn:aws:ssm:region:account-id:document/SSM-SessionManagerRunShell" 
                ],
                "Condition": {
                    "BoolIfExists": {
                        "ssm:SessionDocumentAccessCheck": "true" 
                    }
                }
            },
            {
                "Effect": "Allow",
                "Action": [
                    "ssm:DescribeSessions",
                    "ssm:GetConnectionStatus",
                    "ssm:DescribeInstanceProperties",
                    "ec2:DescribeInstances"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "ssm:TerminateSession",
                    "ssm:ResumeSession"
                ],
                "Resource": [
                    "arn:aws:ssm:*:*:session/${aws:username}-*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "kms:GenerateDataKey" 
                ],
                "Resource": "key-name"
            }
        ]
    }
    

    参考: https: //docs.aws.amazon.com/systems-manager/latest/userguide/getting-started-restrict-access-quickstart.html#restrict-access-quickstart-end-user

    • 1

相关问题

  • 权限被拒绝(公钥)。从本地 Ubuntu 到 Amazon EC2 服务器的 SSH

  • 管理员如何管理他们的 EC2 EBS 和快照?

  • 云有多大?[关闭]

  • EC2 映像启动

  • 如何将安全组添加到正在运行的 EC2 实例?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve