Crontab Rsync without Password

Perform rsync asks for password on the remote server before starting the transfer. Sometimes we need to run rsync by crontab where it is not possible to give password.  Here is a solution to use crontab to execute rsync without any password.

This is helpful when you are scheduling a cron job for automatic backup using rsync.


Rsync to remote server use ssh. So,Now setup ssh so that it doesn’t ask for password when you perform ssh. Use ssh-keygen on local server to generate public and private keys.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Note: When it asks you to enter the passphrase just press enter key, and do not give any password here.

Use ssh-copy-id, to copy the public key to the remote host.

ssh-copy-id -i ~/.ssh/

Note: We are using as the remote server. Here you will have to replace this IP with your remote server. The above will ask the password for your account on the remote host, and copy the public key automatically to the appropriate location.

Now, you should be able to ssh to remote host without entering the password. And thus also Rsync.

Now let you have a different ssh port on the remote server. You have to use below code.

ssh-copy-id -i ~/.ssh/ "root@ -p 99"

99 should be replaced by the ssh port of your remote server.

That is it. 🙂 . Thank You.