Incremental file unidirectional sync with Rsync via SSH Without Password
1. Installation of Rsync.
$ sudo apt-get install rsync
2. ssh-keygen generates keys.
Setup ssh so that it doesn’t ask for password when performing ssh. Use
ssh-keygen on local machine to generate public and private keys.
When prompted, do not input any password, just press Enter.
~/.ssh/id_rsa will be created. This is the identity to be used by the local machine to communicate to remote. (If this file is created as user1, you have to copy it in .ssh/ directory of root to also enable connections without password as a root.
~/.ssh/id_rsa.pub also generated by the previous procedure, will have to be copied to the remote machine.
3. Copy of Public Key to remote machine.
$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_machine
####3. Running rsync for syncing files from local to remote machine.
Note This procedure is unidirectional. For bidirectional sync please check Unison.
$ rsync -azP /pat/to/source/folder/ user@destination_machine:/path/to/folder/
This command will check the diff between source and destination files and change the remote version to the most updated version on the local machine. This is done only sending the incremental part, and compressing it if the
z option is used as in the present example.