Sometimes when you are trying to do ssh from a linux machine you may see this message:
|
Host key verification failed
When you see the message above it indicates that the ssh key found in your known_hosts file has a different key than the system you are trying to ssh into. This usually happens if the destination changes but the IP remains the same. For instance if this IP is a router on the network that you’ve ssh’d into before and the router gets replaced with a new one, the new router will have a different ssh key. The message indicates exactly which file and even what line the ssh key is located in.
If you trust the destination you are trying to get to is the right one the best way to fix this is to go delete the offending ssh key.
Use your favorite text editor such as vi or nano and edit the file. Here we’ll use vi:
vi /Users/user/.ssh/known_hosts
The location of this file will be in the error message you received earlier.
Then you can either search for the the IP of the system you’re trying to ssh into like:
/192.168.1.1
Or go directly to the line that it indicated in the error message:
:5
The line should look something like this:
|
Delete the line save and quit.
dd
wq
Now try your ssh session again and you should no longer be getting the error.
If there is a problem with a the known_hosts
file getting screwed up it is safe to delete the known_hosts
file entirely. It will also delete any of your saved ssh keys but you will simply be prompted to accept them next time you ssh to something.
Comments