How to automatically accept the remote key when rsyncing?

Bravo Delta picture Bravo Delta · Aug 8, 2013 · Viewed 38.9k times · Source

I'm attempting to make a system which automatically copies files from one server to many servers. As part of that I'm using rsync and installing SSH keys, which works correctly.

My problem is that when it attempts to connect to a new server for the first time it will ask for a confirmation. Is there a way to automatically accept?

Example command/output:

rsync -v -e ssh * root@someip:/data/
The authenticity of host 'someip (someip)' can't be established.
RSA key fingerprint is somerandomrsakey.
Are you sure you want to continue connecting (yes/no)? yes

Answer

Yorik.sar picture Yorik.sar · Aug 8, 2013

You can add this host's key to known_hosts beforehand like this:

ssh-keyscan $someip >> ~/.ssh/known_hosts