How do I change the key pair for my ec2 instance in AWS management console? I can stop the instance, I can create new key pair, but I don't see any link to modify the instance's key pair.
This answer is useful in the case you no longer have SSH access to the existing server (i.e. you lost your private key).
If you still have SSH access, please use one of the answers below.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-lost-key-pair
Here is what I did, thanks to Eric Hammond's blog post:
/dev/xvda1
volume (let's call it volume A) - see here/dev/xvdf
(or /dev/sdf
)/mnt/tmp
$ sudo mkdir /mnt/tmp; sudo mount /dev/xvdf1 /mnt/tmp
~/.ssh/authorized_keys
to /mnt/tmp/home/ubuntu/.ssh/authorized_keys
/dev/xvda
.pem
fileThat's it.