Home > English > Knowledge Base > How to synchronize folders with Rsync without a password

How to synchronize folders with Rsync without a password


Rsync is a widely-used widget to store copies of a folder in two computer system. It is usually found in Unix systems with functionalities such as folder synchronization and folder transference. Rsync algorithms, a type of encoding, is used to decrease the network use. Zlib can be used to zip additionally, SSH or stunnel can be used to secure the data.

You should use it together with a crontab Click here or icron

1. Install rsync , synchronize and backup folders

Install Rsync on 2 vps which need synchronizing

 # yum install -y rsync

Command to perform synchronization or backup

# rsync <options> ssh /source folder/ user@ip-vps goal:/goal folder/

Options of rsync

--delete - delete folders unexistent on the sender's system

-v         - provide more details

-a         - saving mode - it preserves (owners, groups), time, representing link, and devices

-e         - "SSH options" - locate ssh

-z         - zip the data folder during the proccess of transference


Ex: we have/source-folder/ synchronize to the address107.189.160.9:/goal-folder/ we type the command

# rsync -avze ssh /source-folder/ [email protected]:/goal folder/

2. Creat keygens to log in without a password

# ssh-keygen

If there are any of these following questions, press enter

Enter folder in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again: 

# ssh-copy-id -i ~/.ssh/id_rsa.pub ip-vps to access

Ex :if we want to access the ip do as follows

3.Test the rsync you will not be asked for your password

# rsync -avze ssh /source-folder/ [email protected]:/goal-folder/

 4.key gen errors

@ssh-keygen error

Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for has changed and you have requested strict checking.
Host key verification failed.

# fix error
# rm -rf /root/.ssh/known_hosts