Remove key from known_hosts
The simplest solution is:
rm -f .ssh/known_hosts
ssh will recreate the file again, but you lose key checking for other hosts!
Or, you can use:
ssh-keygen -R "hostname"
Or the ssh "man-in-the-middle" message should indicate which line of the known_hosts file has the offending fingerprint. Edit the file, jump to that line and delete it.
There is an ssh-keygen switch (-R
) for this.
man ssh-keygen
reads:
-R
hostnameRemoves all keys belonging to
hostname
from aknown_hosts
file. This option is useful to delete hashed hosts (see the-H
option above).
sed -i '6d' ~/.ssh/known_hosts
Will modify the file ~/.ssh/known_hosts:6 , removing the 6th line.
In my opinion, using ssh-keygen -R
is a better solution for an openssh power user, while your regular Linux admin would do better to keep his/her sed skills fresh by using the above method.