1. BySSHExecutionrsync(requires password)
Perform rsyncwith an SSH account (requiring a password) to mirror files to the remote server synchronously.
The following example synchronizes the local/home/ramesh to the remote directory/backup/ramesh (server address 192.168.200.10).
When you do the following, the server prompts the user to log on with a password.
RSYNC-AVZ-E ssh/home/ramesh/[Email protected]:/backup/ramesh/ |
2. Using Ssh-keygen to generate keys
Now let's set up ssh so that you don't need a password to perform an SSH operation, and use Ssh-keygen to generate the public and private keys locally.
$ ssh-keygenenter Passphrase (empty for no passphrase): Enter same passphrase again: |
Tip: When prompted to enter a password, just enter two times the ENTER key, not the password character.
3. Copy the public key to the remote host using Ssh-copy-id
Executes the ssh-copy-id and copies the public key generated by the Ssh-keygen to the remote host.
Ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.200.10 |
Tip: When you do this, you will be prompted for a remote host account and password, and the public key will be automatically copied to the remote directory.
4. No password to execute via SSHrsync
Now you can ssh to a remote host without the need for a password
To perform Rsyncagain, you should not be prompted to enter the password now.
RSYNC-AVZ-E ssh/home/ramesh/[Email protected]:/backup/ramesh/ |
Sync files without a password by executing rsync via SSH