Linux / Unix: Disable OpenSSH Host Key Checking

In OpenSSH, host key checking is a security feature that is enabled by default. It prevents man-in-the-middle attacks by verifying that the server you are connecting to is the one you intended to connect to, by checking its host key against the list of known host keys stored in your local machine.

However, in some cases, you may want to disable host key checking temporarily, for example, when testing a new connection to a remote server. To disable host key checking, you can use the StrictHostKeyChecking option in the ssh configuration file, which is usually located at ~/.ssh/config:

Host *
StrictHostKeyChecking no

Alternatively, you can pass the -o StrictHostKeyChecking=no option on the command line when connecting to a remote server using ssh:

ssh -o StrictHostKeyChecking=no user@host

Note that disabling host key checking is not recommended in production environments, as it can leave you vulnerable to man-in-the-middle attacks. Instead, you should consider adding the host key of the remote server to your known hosts file (~/.ssh/known_hosts) or verify the host key fingerprint manually before connecting to the remote server for the first time.

(https://www.colburnschool.edu/)

Leave a Comment