How to remove hosts or ipaddress from .ssh known hosts

If you move a server around you might have problems with a known hosts file. You would get an error saying:

Warning: the ECDSA host key for '' differs from the key for the IP address '123.456.789.101'

You can remove a hostname / domain from known host like so:

ssh-keygen -R "hostnames"

You can remove an ip address from known hosts file like so:

ssh-keygen -R "123.456.789.101"

Leave a Reply