The problem

Dist /* to remote /home/fn1/demoRsync - avz -- delete dist / * [email protected]: / home/fn1 / demoCopy the code

To copy files to the remote server, run the command above and enter the password of the remote server.

But every time need password, a little tedious, I am a little lazy, so there is this article

To solve

1. Generate SSH public and secret keys locally

Now let’s configure SSH so that rsync over SSH does not require a password. Run the ssh-keygen command to generate public and secret keys on the local server.

ssh-keygen
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Copy the code

Note: When it asks you to enter passphrase press Enter, there is no need to give any password.

2. Run the ssh-copy-id command to copy the public key to the remote host

SSH - copy - id - I ~ /. SSH/id_rsa pub [email protected]Copy the code

Note: This will require you to enter your remote host account and password, and the public key will be automatically copied to the remote directory.

3. Perform rsync over SSH without password

Now you can connect to a remote host over SSH without a password

SSH 106.52.242.123Copy the code

Run rsync again and it will no longer ask you for a password

Rsync - avz -- delete dist / * [email protected]: / home/fn1 / demoCopy the code

other

Toutiao. IO/posts/onvhn…