Host Key Verification Failed with sshpass rsync

khm picture khm · Jun 2, 2017 · Viewed 23.3k times · Source

On my linux server I run the command:

sshpass -p 'password' rsync -avz /source/folder/ [email protected]:/dest/folder

When I run the command without sshpass it will provide me with prompts for authenticity of host and the password.

I need some equivalent to "-o StrictHostKeyChecking=no" (which I use for ssh) that will allow me to run this with no prompts or errors.

Everything I saw from googling was about ssh throwing the error not rsync.

Answer

Jakuje picture Jakuje · Jun 4, 2017

If you want to connect to new server, which public key is not yet in your ~/.ssh/knonwn_hosts, you should not skip this only security check, but rather store the server host key in the known_hosts manually, verify that it is correct and then make the automatic check working.

Simplest way to get the known hosts populated with the server host key is using

ssh-keyscan server-ip >> ~/.ssh/known_hosts

After that, you should not need to use the StrictHostKeyChecking=no workaround.