1. Through ssh, you can execute rsync (password required)

Execute rsync to ensure that the password of your account can be used on the remote server and that files can be copied to the remote server.

For example: synchronize the local directory/home/linuxprobe to the remote directory/back/linuxprobe (server address: 192.168.200.10). When you perform this operation, the server will ask you to enter a password

rsync -avz -e ssh /home/linuxprobe / linuxprobe@192.168.200.10 :/backup/linuxprobe/

  1. Use ssh keygen to generate the key

Now let's configure ssh so that the password is not required when executing rsync through ssh. Use ssh keygen on the local server to generate the public key and secret key.

$ ssh-keygen

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Note: When it asks you to enter passphrase and press enter, no password is required.

  1. Use ssh copy id to copy the public key to the remote host

Use the ssh copy id command to copy the public key to the remote host

ssh-copy-id -i ~/.ssh/id_ rsa. pub 192.168.200.10

Note: When performing the above operations, you will be asked to enter the remote host account and password, and then the public key will be automatically copied to the remote directory.

  1. Perform rsync through ssh without password

Now, you can connect to the remote host through ssh without password

ssh 192.168.200.10

Run rsync again, and it will no longer require you to enter a password

rsync -avz -e ssh /home/linuxprobe/ linuxprobe@192.168.200.10 :/backup/linuxprobe/

Was this answer helpful? 0 Users Found This Useful (0 Votes)