ssh: The authenticity of host ‘hostname’ can’t be established

Depending on your ssh client, you can set the StrictHostKeyChecking option to no on the command line, and/or send the key to a null known_hosts file. You can also set these options in your config file, either for all hosts or for a given set of IP addresses or host names.

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

EDIT

As @IanDunn notes, there are security risks to doing this. If the resource you’re connecting to has been spoofed by an attacker, they could potentially replay the destination server’s challenge back to you, fooling you into thinking that you’re connecting to the remote resource while in fact they are connecting to that resource with your credentials. You should carefully consider whether that’s an appropriate risk to take on before altering your connection mechanism to skip HostKeyChecking.

Reference.

Leave a Comment