I have an AMI that I created a few weeks ago. I want to launch a new AWS EC2 instance and provide that AMI as the image. Problem is, I can't ssh into that box now.
I have tried to attach a new key pair when launching the new instance, but it's as if the configuration of the SSH keys on the box is ignoring my newly attached key pair.
Is there a way to overcome this issue?
I know my new key pair works, I've tested it on a totally blank new instance and I can SSH in just fine.
Any help is greatly appreciated!
The keypair is only copied to the Amazon EC2 instance the first time that the disk is booted. Since you have already booted from that disk (or a disk from which the image was made), it will not copy the keypair again.
You will need to copy a new keypair to the /home/ec2-user/.ssh
directory. This can be done by attaching the EBS volume to a different instance:
Instance 1
)/dev/xvda
)Instance 2
)/home/edc2-user/.ssh/authorized_keys
file and insert your desired public keyInstance 1
, re-attach it to Instance 2
Instance 1
and ssh to it using your new keypairSee documentation: Connecting to Your Linux Instance if You Lose Your Private Key