We are attempting to speed up the installation of oracle nodes for RAC installation. this requires that we get ssh installed and configured so that it doesn't prompt for a password.

The problem is: On first usage, we are prompted for

RSA key fingerprint is 96:a9:23:5c:cc:d1:0a:d4:70:22:93:e9:9e:1e:74:2f.
Are you sure you want to continue connecting (yes/no)? yes

Is there a way to avoid that or are we doomed to connect at least once on every server from every server manually?


Set StrictHostKeyChecking no in your /etc/ssh/ssh_config file, where it will be a global option used by every user on the server. Or set it in your ~/.ssh/config file, where it will be the default for only the current user. Or you can use it on the command line:

ssh -o StrictHostKeyChecking=no -l $user $host

Here's an explanation of how this works from man ssh_config:

         If this flag is set to “yes”, ssh will never automatically add
         host keys to the $HOME/.ssh/known_hosts file, and refuses to
         connect to hosts whose host key has changed.  This provides max-
         imum protection against trojan horse attacks, however, can be
         annoying when the /etc/ssh/ssh_known_hosts file is poorly main-
         tained, or connections to new hosts are frequently made.  This
         option forces the user to manually add all new hosts.  If this
         flag is set to “no”, ssh will automatically add new host keys to
         the user known hosts files.  If this flag is set to “ask”, new
         host keys will be added to the user known host files only after
         the user has confirmed that is what they really want to do, and
         ssh will refuse to connect to hosts whose host key has changed.
         The host keys of known hosts will be verified automatically in
         all cases.  The argument must be “yes”, “no” or “ask”.  The
         default is “ask”.
  • 1
    +1, I also this for my servers. And just to be clear, the message in the question comes from the ssh client on the connecting client computer and not from the server. – Patkos Csaba Mar 2 '12 at 20:53
  • 2
    This answer sounds like a security problem in the making. – SunSparc Jun 15 '16 at 20:59

ssh-keyscan - Gather ssh public keys

If you already know the list of hosts you will connect to, you can just issue:

ssh-keyscan host1 host2 host3 host4

You can give the -H option to have it hash the results like ssh defaults to now

Also you can give -t keytype were keytype is dsa, rsa, or ecdsa if you have a preference as to which type of key to grab instead of the default.

Once you have run ssh-keyscan it will have pre-populated your known-hosts file and you won't have ssh asking you for permission to add a new key.

  • 1
    I'm a little puzzled about the "will have pre-populated" comment... known_hosts isn't created or modified after running this. You mean the contents can be piped to the file to populate it? – rschwieb Mar 23 '18 at 13:57
  • 3
    Confirming with techrepublic.com/article/… . ssh-keyscan -H myhost >> ~/.ssh/known_hosts, or for server-wide, /etc/ssh/ssh_known_hosts – cole Aug 1 '18 at 1:47

You can add the fingerprint to each server's known_hosts. For a single user:

cat ~/.ssh/known_hosts
echo "$SERVER,$PORT ssh-rsa $SERVER_KEY_FINGERPRINT" >> ~/.ssh/known_hosts
  • 3
    This is no more the right way to do it since when hashing was introduced. – Deim0s Apr 20 '15 at 9:38

Ignore Host

Ignore the HostKeyChecking. For this I use e.g.:

ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null user@example.net

Add Host

Add the host's/server's fingerprint to .ssh/known_hosts prior to your first connect. This is the safer way.

  • Hi. Oracle issue the ssh command so I have no control over how it performs this. – Nicolas de Fontenay Mar 2 '12 at 22:49
  • Upvoted. Most of the answers I've seen miss the mentioning of dev nulling the known hosts file. This makes the command much more usable and won't ruin any existent config. – Alex Feb 22 at 14:40

Execute the following snippet before trying.

mkdir -p ~/.ssh     
echo "Host *" > ~/.ssh/config     
echo " StrictHostKeyChecking no" >> ~/.ssh/config

ps: Strictly not for production servers, beware of ManInMiddle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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