tags:

views:

59

answers:

2

On Amazon EC2 is it possible to reassign a keypair to an already running instance?

I am having problem with a particular keypair and am wondering if there is a way to fix it by reassign it.

Thanks

+2  A: 

The best solution we have been able to come up with is to burn an AMI from the running instance and launch a new instance from that AMI using the new key pair.

Every instance we launch is based on a custom AMI that we maintain for this and many other reasons.

I'm interested to hear if anyone has a better approach.

Eric J.
How do you burn an AMI for the instance? Does that capture all of the data as well?
resonantmedia
See http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?PreparingAndCreatingAMIs.html for how to create your own AMIs.
gareth_bowles
A: 

Probably ... just guessing based on what I've done in a few instances:

  1. Log into the instance with ssh. If that's the problem, you're pretty much stuck
  2. SFTP the public key from the new pair and put it in place in the .ssh authorized keys
  3. Restart the sshd

Now, try accessing with the private key that matches the public one you put in place.

But I fear the problem you have is getting in when the pair AWS put in place has gone bad. No help there.