How do I skip the "known_host" question the first time I connect to a machine via SSH with public/private keys?
All the other current answers are missing the UserKnownHostsFile=/dev/null
If you just want to do it once you can use:
ssh -o StrictHostKeychecking=no hostname
If you want to do it repeatedly you should add something like the following to your ~/.ssh/config
Host 192.168.0.* StrictHostKeyChecking no UserKnownHostsFile=/dev/null
To configure this on OpenSSH for Windows simply replace
Good explanation from: http://linuxcommando.blogspot.com/2008/10/how-to-disable-ssh-host-key-checking.html
This took me a while to find. The most common usecase I've seen is when you've got ssh tunnels to remote networks. All the solutions here produced warnings which broke my scripts (nagios).
The option I needed was:
Which, as the name suggests also only applies to localhost.
You can disable the checking, but of course that is less secure. In an ideal situation what you should do is get someone that already has access to the machine to grab it's public host key and tell ssh to use it. i.e.: take the output of:
prepend the hostname of the machine, and add that line to the ~/.ssh/known_hosts file on your machine. You'll end up with something that looks like:
myhost.example.com ssh-rsa AAAAB3Netc...
Alternately, if you just want to grab the fingerprint of the key, which may be easier to transfer over a limited bandwidth channel (like a phone call), you can have your helper run:
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub