Error accessing amazon's EC2 instance via ssh

2

I'm trying to access an Amazon EC2 instance via ssh from my linux-ubuntu. I already created the machine on the amazon console, I created a key pair, so I did what I did (for what I understood I had to do) on my pc, I went to the folder where I downloaded my-key-pair.pem and then I ran the command

chmod 400 my-key-pair.pem

after

ssh -i my-key-pair.pem [email protected]

And then you gave me this error

Warning: Permanently added '51.207.86.54' (ECDSA) to the list of known hosts.
Permission denied (publickey).

Am I doing something wrong or anything from a startup in this aws.amazon world?

    
asked by anonymous 24.04.2014 / 05:38

2 answers

4

The error message does not indicate a connectivity problem, but rather an authentication problem.

Some possible causes:

  • You are passing in the parameter -i a private key that does not correspond to the Key Pair with which you launched the instance (note that it is not the "name" of the file that imports, but the content - if you have created the Key Pair, deleted, and re-created with the same name, then there are 2 distinct Key Pairs and it will not work);
  • username ubuntu does not match the AMI default username you chose;
  • You are using a "weird" AMI, which does not properly set the public key on the user;
  • You launched the instance without associating a Key Pair with it during creation;

Only with the information that you gave, is it very difficult to determine the problem. Follow the suggestions above, and if you can not, try adding more information to the question.

    
07.05.2014 / 11:53
1

Have you registered the key generated on your PC in the list of SSH Keys enabled for connection?

Use:

cat ~/.ssh/id_pub.rs

It will display the key, then copy it and save it in the list in the administrative panel of the server.

For more infos, follow this tutorial on how to generate the key and save it: link

    
24.04.2014 / 13:30