Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have access to the console panel for EC2. There exists one key pair (created by someone prior).

I created a second key-pair, and then tried to SSH in to the ec2 instance. This is what happens:

PREMIEREs-Mac-Pro:.ssh Premier_032$ ssh -i ~/.ssh/david.pem ubuntu@50.11.111.111
Permission denied (publickey).

What do I need to do in order to SSH to EC2 here, and is ubuntu the correct username (I also tried root, which didn't work either).

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Adding a keypair to EC2 doesn't add it to running instances. EC2 only installs keypairs when an instance is launched. You'll need to obtain the keypair used to launch the instance, or have whoever launched it add your public key to the /home/ubuntu/.ssh/authorized_keys file.

share|improve this answer
add comment

I'm pretty sure a running instance isn't going to install a new public SSH key you added to the account. You'll need to start up a new instance and then select the keys you want to use to access it.

It's hard to say what the username will be. It would depend on the AMI.

share|improve this answer
add comment

If you need to access that specific instance there is possibly a workaround to your situation. You will need access to the AWS Web Console and the instance will need to be a EBS backend instance. What you will need to do is;

  1. Stop the running instance. (Do Not Terminate it, just shut it down for now)
  2. De-attach the EBS backend from the instance
  3. Create a new EC2 instance.
  4. On new system, create a mount point /mnt/oldsystem
  5. Attach EBS backend from old instance to the new instance and mount it as /mnt/oldsystem

You should now have access to the file system of the old instance. Navigate the the user account you want to log in as, assuming ubuntu from your post, and add your new ssh key to the .ssh/authorized_keys file (path should be /mnt/oldsystem/home/ubuntu/.ssh/authorized_keys)

Once you are done, unmount /mnt/oldsystem and de-attach the EBS backend. Now you can re-attach the EBS to your original instance, start the instance up, and you should be able to use your SSH key to log into the account now.

share|improve this answer
    
Definitely a good idea. Alestic has a fairly thorough tutorial for dealing with this: alestic.com/2011/02/ec2-fix-ebs-root –  Tom Feb 1 '12 at 7:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.