How can I force ssh to accept a new host fingerprint from the command line?

The answers here are terrible advice. You should never turn off StrictHostKeyChecking in any real-world system (e.g. it’s probably okay if you’re just playing on your own local home network – but for anything else don’t do it).

Instead use:

ssh-keygen -R hostname

That will force the known_hosts file to be updated to remove the old key for just the one server that has updated its key.

Then when you use:

ssh user@hostname

It will ask you to confirm the fingerprint – as it would for any other “new” (i.e. previously unseen) server.

Leave a Comment