Rsync cron job with a password

croncronjobrsync

I want to set up an rsync command as a cron job, so I need to find a way to supply my server password automatically to rsync.

Currently I have a shell script that looks like this:

#!/bin/sh
rsync *.rss me@myserver.com:/home/dir --password-file ~/rsync.password

The rsync.password file just contains my password.

However, when I run the script, I get:

The --password-file option may only be used when accessing an rsync daemon.
rsync error: syntax or usage error (code 1) at main.c(1241) [sender=3.0.7]

Could anyone let me know how to fix this, so I can start to run the shell script as a cron job?

Best Answer

What you really want to do is look at setting up public keys between the servers so they 'trust' each other and passwords are not needed.

Have a read here:

http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/

http://blogs.oracle.com/jkini/entry/how_to_scp_scp_and

Related Question