Here is a walkthrough on how to utilize ssh public and private keys to transfer files via ssh and rsync on Linux. This will be accomplished without a password and on a scheduled basis using cron.
Computer1 (192.168.0.1) – machine running rsync of /home/bob from crontab.
Computer2 (192.168.0.2) – machine receiving files (/home/bob) from computer 1 and writing to /home/bobbackup via ssh and rsync.
login to computer1 as user bob and complete the following:
run ssh-keygen (except defaults and blank passphrase, to place the private and public keys in the current user’s home directory “.ssh” folder)
cat /home/bob/.ssh/id_rsa.pub > /tmp/authorized_keys | scp /tmp/authorized_keys firstname.lastname@example.org:/home/bob/.ssh/authorized_keys
accept the key and type your password, and the ssh portion is done for communications from computer1 to computer2 without the need for a password.
All that is left is setup the rsync info in the user bob’s crontab.
As the user bob run crontab -e (this will probably default to the vi editor, it may be a little odd for those unfamiliar) and save the following to the crontab.
59 23 * * * /usr/bin/rsync -auEve ssh /home/bob email@example.com:/home/bobbackup
This will run as the user bob at 11:59pm every night of every month of every day of the week. Thanks to the “u” in rsync after the initial copy it will only send the files that have changed.