Error accessing Amazon EC2 instance via ssh

Asked

Viewed 2,542 times

1

I am trying to access an Amazon EC2 instance via ssh from my linux-Ubuntu. I already created the machine in the console of Amazon, I created a key pair , hence what I did (so I understood I had to do) on my pc, I went to the folder where downloaded the my-key-pair.pem and from there I ran the command

chmod 400 my-key-pair.pem

afterward

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

and then gave me this mistake

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

I’m doing something wrong or anything from a beginner in this aws world.?

  • 2

    Good young man, I believe that this is not the right place for questions that are not relating to programming. Maybe you should modify it a little bit.

  • So @Eduardobrj I imagine that here is actually a good place for this question, but anyway, it’s just a problem I’m having, but I keep looking elsewhere without problems. I don’t see much to change, in case you see free to edit. Valew and if you know something to help I appreciate.

  • See if your IP is cleared to access the instance in the AWS security settings.

  • Sorry, at no time I wanted to tell you "what to do", I am following the community that focuses on solving problems related to programming, I do not see SSH as programming (mainly key problem), but who am I to juggle. Sorry for any inconvenience. Good Luck.

  • As answered by Bruno Reis, the error seems to be related to the user used in the "Ubuntu" connection, with the EC2 user, the user must be the same as AMI, otherwise you receive this error. You can try connecting using the following command ssh -l USUARIO_DA_EC2 -i my-key-pair.pem ec2-51-207-86-54.sa-east-1.compute.amazonaws.com

4 answers

4

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

Some possible causes:

  • you are passing in parameter -i a private key that does not match the Key Pair you launched the instance with (note that it is not the "name" of the file that matters, but rather the content -- if you have created the Key Pair, deleted, and created again with the same name, then it is 2 distinct Key Pairs and it will not work);
  • the username ubuntu does not match the user name pattern of the AMI you chose;
  • vc is using a "weird" AMI, which does not properly configure the public key in the user;
  • vc launched the instance without associating her a Key Pair during creation;

With the information you’ve given, it’s very difficult to determine the problem. Follow the suggestions above, and if you can’t, try adding more information to the question.

1

You registered the generated key on your PC in the connection-enabled SSH Keys list?

Use:

cat ~/.ssh/id_pub.rs

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

For more background, follow this tutorial on how to generate the key and save it: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

  • 1

    I tried to do this tbm but it didn’t work ... Still thank you so much

  • The default user to access for ssh is ec2-user. ;ssh -i my-key-pair.pem [email protected]

  • 1

    Alamops. VLW CARA. It was exactly the default user that was missing in mine to access.

0

You must generate the . PPK file from your . PEM file using the Puttygen (64 bits) and then use it, the . PPK as a private key for instance access.

0

I got it using like this ssh -i <sua.pem> Ubuntu@<dns of your instance> I believe you need Ubuntu@ to identify the instance user, in which case mine is an instance of Ubuntu and a Ubuntu default user is created'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.