WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

October 15, 2014 91.5k views

I've got this message below when trying to connect via SSH.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
51:82:00:1c:7e:6f:ac:ac:de:f1:53:08:1c:7d:55:68.
Please contact your system administrator.
Add correct host key in /Users/isaacalves/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/isaacalves/.ssh/known_hosts:12
RSA host key for 104.131.16.158 has changed and you have requested strict checking.
Host key verification failed.

I had overwritten my previous key in my computer and used it with a new droplet (not the one I tried to connect when getting this message. That one actually asks for a password I have not received via e-mail)

Thinking that this message was probably related to that, I updated my SSH key in Digital Ocean with that new one from my computer again. But the message continued to show when trying to login in via ssh.

Is that normal?

3 comments
  • Since you updated your ssh key, getting the above message is normal.

    Just edit ~/.ssh/known_hosts and delete line 12, as the message pointed you

    Offending RSA key in /Users/isaacalves/.ssh/known_hosts:12
    

    or use ssh-keygen to delete the invalid key

    ssh-keygen -R "you server hostname or ip"
    
  • you saved my bacon thank you!!!

  • This worked beautifully, thanks!

6 Answers

It is not necessary to delete the entire known_hosts file, just the offending line in that file. For example if you have 3 server as follows.

vi +2 .ssh/known_hosts 

Now go to line # 2, type the following command

:2

Now delete line with dd and exit:

dd
:wq

Very thanks

resolved for me is

ssh-keygen -R "you server hostname or ip"

cool, but I've spent a couple of minutes figuring out what's "you server". Actually it's not your server ip but remote host name or ip as shown in known_hosts on line mentioned in error

Thanks!

ssh-keygen -R "you server hostname or ip"

Have another answer? Share your knowledge.