Saturday 26 July 2014

SSH: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

 You get an error like this:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
[MAC Address]
Please contact your system administrator.
Add correct host key in [known_hosts folder] to get rid of this message.
Offending key in [line number in known_hosts folder]
RSA host key for [host you were trying to connect to] has changed and you have requested strict checking.
Host key verification failed.


There are two solutions (both are easy):
  1. Run ssh-keygen -R hostname. According to the man page this: "Removes all keys belonging to hostname from a known_hosts file."
  2. Manually delete the entry on the provided line number in your known_hosts folder. You can find known_hosts/ in .ssh/

For more details see here