AWS doesnt let you change your ec2 instance key from the admin console.
If you need to replace a key for an ec2 instance:
-
if you already have the key/pub generated, jump to #3.
-
Create a new key from command line:
ssh-keygen -t rsa -C "my-new-key"
Chose a name and add .pem as extention.
This will create two files, a .pub and a .pem
-
Log into you instance as the user you want to change key, or simly root
-
Edit the
~/.ssh/authorized_keys
copy the content of the pub file and save it.
Will be somethign like this: ssh-rsa 2e+Mk2Y3mfswFpno9....long bla bla...3442f2A pepe
- Now try to login, the id file is your new pem file as usual
ssh -i "pepe.pub.pem" root@ec2-7-10-54-11.compute-1.amazonaws.com
- Delete other old keys from authorized_keys if you want.