Connect with SSH at AWS instance [closed]


I have an instance of Ubuntu created in AWS, I have generated the .pem to connect with SSH in the following way: ssh -i my_key.pem user @ ip

My surprise is that I was able to connect from the terminal of my Mac the first time but if I want to connect again it tells me the following:

ssh -i mi_key.pem [email protected]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is 9f:24:59:52:38:78:de:9f:bb:f1:e0:69:3e:b1:5b:af. Please contact your system administrator. Add correct host key in /Users/sergio/.ssh/known_hosts to get rid of this message. Offending RSA key in /Users/sergio/.ssh/known_hosts:31 RSA host key for "ip" has changed and you have requested strict checking. Host key verification failed.

asked by Sesiño Perezma 27.07.2016 в 18:20

1 answer


Excuse me, I've already solved it:

The file where keys are stored on the local computer is /home/user/.ssh/known_hosts. As indicated by the error message, in this case it is the first key saved:

Offending key in /home/user/.ssh/known_hosts:1

You can edit this file and delete that key but it's simpler to use the ssh-keygen command with the -R option

user @ sorse: ~ $ ssh-keygen -R

If the standard ssh port were used, it would suffice to indicate the name of the remote device after the -R option.

answered by 27.07.2016 в 18:29