Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As far as I know the default ssh option StrictHostKeyChecking is set to ask so the first ssh connection seems like:

$ ssh
The authenticity of host ' (' can't be established.
RSA key fingerprint is 52:9b:0a:f1:e4:51:1b:96:8c:b7:96:7c:d3:d2:7d:9f.
Are you sure you want to continue connecting (yes/no)?
  • I'd like to automatically add host key for the first time assuming the possible security issue.
  • I'd like the host key to be used by any local user automatically (e.g. without any extra ssh command-line options).
share|improve this question

migrated from Mar 12 '13 at 9:50

This question came from our site for professional and enthusiast programmers.

1 Answer 1

I've read man ssh and man ssh_config and figured out the solution for this:


for host in \ \ \
; do
    ssh-keygen -R $host -f $SSH_KNOWN_HOSTS
    ssh -q -o StrictHostKeyChecking=no -o BatchMode=yes -o UserKnownHostsFile=$SSH_KNOWN_HOSTS $host echo '' || true
chmod a+r $SSH_KNOWN_HOSTS

It works but seems hacky. Do you know a shorter way to do this ?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.