EC2 instance can be accessed by using different account pem if your ip address is whitelist for same region

0

Hi, EC2 instance can be accessed by using different account pem if your ip address is whitelist for same region. Is it expected or bug from aws side?

  • Whay do you mean by account pem ?

  • Question makes no sense

  • can you clarify and give more context?

  • I mean that I am able to use access key of aws account A to access EC2 instance of another aws account B in same region.

Ranjeet
asked a year ago287 views
1 Answer
1

A ssh private key (PEM key), is a security credentials that you use to prove your identity when connecting to an Amazon EC2 instance. Neither it has relation with AWS Account nor with AWS regions, rather it is related to the machine/instance.

For Linux instances, the private key allows you to securely SSH into your instance. Key pair can be created using the Amazon EC2 console or a third-party tool.

If you specify a key pair at launch, when your instance boots for the first time, the public key material is placed on your Linux instance in an entry within ~/.ssh/authorized_keys. Additionally you may append the public key on the Linux instance for a specific user, the path to the file is ~/.ssh/authorized_keys.

To fetch the public key from a private key (PEM), you may execute the following command:

$ ssh-keygen -yf ssh_key_name.pem

Since you are able to use the same private key, you must see same public key hash on both the instances in ~/.ssh/authorized_keys.

Anyone who has the .pem can ssh to your instance without the need for any other AWS credentials since the associated public key is available on the instance.

You may refer:

Amazon EC2 key pairs and Linux instances: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

Add or remove a public key on your instance: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

You may also refer the following third-party article:

What is SSH Public Key Authentication? https://www.ssh.com/academy/ssh/public-key-authentication

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions