0

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 [email protected]
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).

3 Answers 3

4

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.

2

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.

2

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .