Where I can get ec2-user pem file to connect ec2 instance from laptop

Hi All,

I am doing AWS Solutions Architect Associate Certification, When i am doing the lab if I want to connect instance from my laptop , I need pem file. Where i can get it. I am able to connect it AWS console. By if want to connect it from my laptop, How i can connect ? Please advise. Thank you.

Run ssh-keygen command to generate a key pair on your local machine, a public key and a private key(default key names id_rsa.pub, id_rsa).

If you are creating a new vm upload this public key.
If you want to connect to existing vm, connect to the vm from AWS console and edit the .ssh/authorized_keys file of ec2-user and add the contents of id_rsa.pub file that you created on your local machine.

1 Like

Hi @akoduri31,

When you create a new EC2 instance, you need to choose an existing key pair or create a new one. Download this key so you can use it to connect to the instance via SSH. Don’t forget to allow port 22 in the security group for the instance.

1 Like