I recently reinstalled a Ubuntu machine on my network. I often log in to that server machine via SSH on my laptop. I received a scary message when trying to do so.
ryan@ryan-laptop:~$ ssh firstname.lastname@example.org
@ 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
Please contact your system administrator.
Add correct host key in /home/ryan/.ssh/known_hosts to get rid of this message.
Offending key in /home/ryan/.ssh/known_hosts:1
RSA host key for 192.168.2.67 has changed and you have requested strict checking.
Host key verification failed.
This took me by surprise. My network is secure as far as I know, and the only difference now is the that I reinstalled my server with a fresh copy of Ubuntu 10.04. When SSH is installed I guess it makes a new RSA key and it’s not based on hardware or anything silly. That makes sense, I guess.
Fixing the error at least on the laptop was effortless. First, I opened the terminal. Then, I ran
vim known_hosts. And I saw a mess of characters appear on my screen. The error message said I could update key 1 but it looked like there already multiple key 1s.
My solution was to simply delete the known_hosts file with
rm known_hosts and remake it with
touch known_hosts. That was easy enough. Then, I tried to run my ssh command again,
ssh email@example.com. It prompted me that this computer has not been accessed before and it isn’t an already trusted key. That’s great, because I did trust it and I accepted it. That means deleting the old file and remaking it worked. Excellent.