$ ssh-keygen -R <hostname>
Jan. 25, 2014, 1:35 p.m.
—
openiduser126
Explanation
The ssh-keygen
tool comes with an option for this already, there is no need for esoteric one-liners that are hard to remember.
Say you ssh server.example.com
and its host key has changed because you just reinstalled it. Run ssh-keygen -R server.example.com
then try to connect to the server again, you'll be presented with the option to save the host key just like new.