You have to clear both the hostname and the ip address from your known_hosts file, you can do it like this:
ssh-keygen -f ~/.ssh/known_hosts -R [somehostname.net]
ssh-keygen -f ~/.ssh/known_hosts -R [123.123.123.123]
Just replace somehostname.net
with the hostname or domain name of the host you want to clear, and replace the ip address with the hosts ip address (leave the square brackets in). If it worked you will see a message like this:
/home/yourname/.ssh/known_hosts updated.
Original contents retained as /home/yourname/.ssh/known_hosts.old
If it didn't work, try the same thing but without the square brackets, also double check that the hostname and ip address is correct:
ssh-keygen -f ~/.ssh/known_hosts -R somehostname.net
ssh-keygen -f ~/.ssh/known_hosts -R 123.123.123.123
If the host's SSH port is on a different port, say 2222 instead of 22 then simply add the port like so:
ssh-keygen -f ~/.ssh/known_hosts -R [somehostname.net]:2222
ssh-keygen -f ~/.ssh/known_hosts -R [123.123.123.123]:2222
vim +1 ~/.ssh/known_hosts
and remove the first line with : dd The line where the offending key is located is the one after the colon, thus line 1 in this case.:1
means line 1,:2
means line two. Offending key on line 1 is the line you need to delete.