If you’ve been doing lots of development on a server build and it’s been redone several times you will no doubt have come across the mild annoyance of SSH checking the host key. An example of such an error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
Please contact your system administrator.
Add correct host key in /home/example/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/example/.ssh/known_hosts:999
RSA host key for 192.168.0.1 has changed and you have requested strict checking.
Host key verification failed.
Whilst normally this is a great thing just now and then you want to quickly ignore it without bothering to remove the offending line in your known_hosts
file. Perhaps you have only temporarily reassigned the IP address or something. What is the solution? Easy just tell SSH to use a different Known Hosts file, a nice empty one like /dev/null
ssh -o UserKnownHostsFile=/dev/null example@192.168.0.1
And you should be prompted to add the key to your nice empty throw away /dev/null
The authenticity of host '192.168.0.1 (192.168.0.1)' can't be established.
RSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.1' (RSA) to the list of known hosts.
Job done.