I've launched a CentOS 6.4 AMI and configured it to act as a base instance for our application. I'm now trying to create an AMI from this which can be brought up as required.
Unfortunately when a new instance is created from the AMI the root user's key pair remains that which was assigned to the original template instance when it was created from a CentOS AMI. I was hoping that AWS would be able to assign a new key pair to each instance of the AMI as it's created. Although we won't be using the root key pair for day-to-day work on the instances, I'd prefer they didn't all share the same key.
Despite creating a new key pair at launch time I'm only able to log in using the original key. I've tried several solutions including removing the authorized_keys for the root user, but to no avail.
I'd appreciate any advice you can provide.
Thanks.
Stop the running EC2 instance
Detach its /dev/sda1 volume (let's call it volume A)
Start new t1.micro EC2 instance, using my new key pair
Attach volume A to the new micro instance, as /dev/xvdf (or /dev/sdf)
SSH to the new micro instance and mount volume A to /mnt/tmp
Copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys
Logout
Terminate micro instance
Detach volume A from it
Attach volume A back to the main instance as /dev/sda1
Start the main instance
Login as before, using your new .pem file