Ubuntu – SSH Warning – Remote Host Identification Has Changed


Using SSH to an IP address that is now being used by a different server will give you this nice warning:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
c8:94:a2:46:8f:c9:d0:d9:fd:33:44:42:9c:9f:ea:58.
Please contact your system administrator.
Add correct host key in /home/mike/.ssh/known_hosts to get rid of
this message.
Offending key in /home/mike/.ssh/known_hosts:2
RSA host key for 192.168.0.41 has changed and you have requested
strict checking.
Host key verification failed.

SSH keys in Ubuntu are stored in the /home/{username}/.ssh/known_hosts file.

The above warning lets me know that the offending key is in line 2 of my known_hosts file.

I can either manually delete line 2 from my known hosts file or run the following command:

ssh-keygen -R {server-ip-address}

In this case I was of course aware of the change in my infrastructure and went ahead and amended my known_hosts file. As the error states you could also be the victim of a man in the middle attack, so be careful!

An IP address change is just one cause of this SSH error – see here for more details.

3 thoughts on “Ubuntu – SSH Warning – Remote Host Identification Has Changed

    1. @ Ahmad – I think that is overkill – I don’t want to get rid of all of my known SSH hosts just because of an issue with one of them – I think my solution is fine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s