1. Perform rsync via SSH (password required)
Perform rsync through an SSH account (requiring a password) to mirror files synchronously to a remote server.
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 in with a password.
Copy Code code as follows:
Rsync-avz-e ssh/home/ramesh/ramesh@192.168.200.10:/backup/ramesh/
2. Use Ssh-keygen to generate keys
Now let's set up SSH so that you do not need a password to perform an SSH operation, and use Ssh-keygen to generate the public and private key locally.
Copy Code code as follows:
$ ssh-keygen
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:
Tip: When prompted to enter a password, just enter the Enter two times, do not refer to 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 Ssh-keygen to the remote host.
Copy Code code as follows:
Ssh-copy-id-i ~/.ssh/id_rsa.pub 192.168.200.10
Tip: When you do this, you will be prompted to enter the remote host account and password, and the public key will be automatically copied to the remote directory.
4. Do not need password through SSH to perform rsync
Now, you can ssh to a remote host without needing a password
Copy Code code as follows:
To perform rsync again, you should not be prompted to enter the password now.
Copy Code code as follows:
Rsync-avz-e ssh/home/ramesh/ramesh@192.168.200.10:/backup/ramesh/