Linux – How to prevent rsync (using ssh as remote shell) from facing a password prompt

linuxrsyncssh

I would like to run rsync without the need to enter a password. I understand I can do this using ssh keys and once the right key has been copied over to the remote server rsync logs in fine without user interaction.

However when the key has been changed, has been removed, or, say in case of some automation, a server has been added to a list of servers to be rsync'ed, I would like rsync to not be prompted for a password.

Meaning, rsync should only attempt to use password-less login with ssh and if that doesn't work move on without having to deal with a password prompt and a possible lengthy timeout.

Best Answer

You can configure the SSH client to not attempt password authentication:

rsync -e 'ssh -o PasswordAuthentication=no' ...

There is also a BatchMode option which disables password authentication and decreases the timeout:

rsync -e 'ssh -o BatchMode=yes' ...
Related Topic