0

While I am connecting to an Amazon-linux-2 instance in which the AWS instance connect was installed by default I am getting the error like this

An error occurred (AccessDeniedException) when calling the SendSSHPublicKey operation: User: arn:aws:iam::7***********:user/EIC-user is not authorized to perform: ec2-instance-connect:SendSSHPublicKey on resource: arn:aws:ec2:eu-west-1:7***********:instance/i-065544409504*****

My Attached IAM Policy for user EIC-user is

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ec2-instance-connect:SendSSHPublicKey",
            "Resource": [
                "arn:aws:ec2:eu-west-1:7312********:instance/i-06554440950******"
            ],
            "Condition": {
                "StringEquals": {
                    "ec2:osuser": "dev"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": "ec2:DescribeInstances",
            "Resource": "*"
        }
    ]
}

In My Ec2 Instance i added a user with named dev by using this command : useradd dev

If i changed the "ec2:osuser": "dev" to "ec2:osuser": "ec2-user" then it is connecting to ec2-user but i want to connect to user dev

I wanted to connect to another user in the OS, Is it possible to login with non-default users other than default users in AWS Instance Connect ????

Everything is going perfect if i used default user.... the error is happening only when i changed the OSuser I wanted to connect to the user dev Please help me to find out.....

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • `dev` is not valid user-name for ec2 instance. `ec2-user` is. If you want `dev` you have to customize your AMI to use such a user as `dev`. This is not something AWS can do for you. – Marcin May 10 '21 at 04:23
  • Thank You For Your Response `Marcin`. I already created a user named `dev` inside my Linux Machine , I am trying to connect to that user using Ec2 Instance Connect... can you please help me with this – Subramanyam Devasani May 10 '21 at 11:22

0 Answers0