AWS instance key problem

having problem matching your ec2 publickey
Written by DEL support01
Updated 8 months ago

When going to create your own server on AWS console, called EC2 instance

you go on to launch a new instance , on the configuration page , you create your key pair (in this case called devops)

Now you go ahead to copy the ssh command to connect to your instance, 

that command has the name of the key associated with the instance (devops.pem)

you copy it from the 2 squares icon , and go to paste it on your terminal.

the key you create gets stored in the downloads folder (ls |grep .pem )

You do your work and then stop your instance and go on.


Few days later you come back and you get this error message trying to connect again

this message indicates it is not finding the key to connect;

after making sure you re in the Downloads directory, type ls |grep .pem to look for all the aws key present in that directory(in case you created multiple ones)
If on the output you see the name of the key for you instance (devops.pem) in our case; its a big problem, you just have to renounce using that instance, or if you have really important stuffs working in it, contact the support team.

if your files in there are expandables, terminate the instance, and launch new one.

the best practice when launching new instance after making sure of the keys in your computer is choosing an existing by clicking on the little icon(first arrow) which will unfold a menu for you to choose among existing keys; then select the key you know is still in your downloads folder ,rudiori.pem here (see img 4) then go on to connect 

now the key matches the one in your Downloads folder and you can go on and work on your own server.

NB: it s best practice to have as few keys as possible for aws, and the same goes for security groups.

Did this answer your question?