How to automatically accept the remote key when rsyncing? How to automatically accept the remote key when rsyncing? shell shell

How to automatically accept the remote key when rsyncing?


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

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


If they genuinely are new hosts, and you can't add the keys to known_hosts beforehand (see York.Sar's answer), then you can use this option:

-e "ssh -o StrictHostKeyChecking=no"


I know that this was asked 3 years ago, but this was at the top of my google search and I was unable to get either of these solutions in the middle of a Vagrant script to work correctly for me. So I wanted to put here the method that I found somewhere else.

The solution there talks about updating the ~/.ssh/config or /etc/ssh/ssh_config file with the following blocks of code.

To disable host key checking for a particular host (e.g., remote_host.com):

Host remote_host.com    StrictHostKeyChecking no

To turn off host key checking for all hosts you connect to:

Host *    StrictHostKeyChecking no

To avoid host key verification, and not use known_hosts file for 192.168.1.* subnet:

Host 192.168.0.*    StrictHostKeyChecking no    UserKnownHostsFile=/dev/null

I hope this helps someone else who runs into this issue.