Step 1 – Setup public SSH keys
On the local server, generate the public SSH keys with no password:
ssh-keygen -f ~/.ssh/id_rsa -q -P "" cat ~/.ssh/id_rsa.pub
This is the public SSH key that can be placed on other hosts to provide no-password required access:
ssh-rsa AAA...[*] root@boomclickclick
Copy this key to your clipboard and login to the remote (destination) server.
Place this SSH key into your ~/.ssh/authorized_keys file:
If your SSH folder does not exist, create it manually:
mkdir ~/.ssh chmod 0700 ~/.ssh touch ~/.ssh/authorized_keys chmod 0644 ~/.ssh/authorized_keys
Step 2: Login to the Remote Server from the Local Server
Now, if you wanted – you could rsync a folder to the remote host without logging in.
Make sure that you have rsync installed on the destination server, and then exit out of the remote server and do the same on your source server. Next, issue an rsync command, something like below, but adjusted to your circumstance. The trailing / in the example below means that I’m syncing a folder and not a file.
rsync -avz -e 'ssh' --delete /foo/bar/test/ email@example.com:/foo/bar/test/
The next project is to create a shell script and create a cron job to run the rsync at a specified interval.
I’ve used this to rsync folders from Apple OS X Mavericks, Scientific Linux 6.5 and Debian Wheezy,
Using Cygwin in Windows 8.1, there is a command need to be run in Windows Cygwin window:
chgrp Users ~/.ssh/id_rsa
Then the solution posted here can be applied, 400 or 600 is OK.
chmod 600 ~/.ssh/id_rsa