Get the App
SLTechnology News&Howtos  ›  Servers  › 

Does scp copy between Linux hosts without entering a password?

Shulou Source: shulou.com Published: 2022-06-01 07:45:43 09月22日 Update

scp replication between Linux hosts do not need to enter a password, I believe many inexperienced people are helpless, for this reason this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Copy your local host user's ssh public key file to the remote host user's ~/.ssh/authorized_keys file, assuming local host linux(10.1.1.1), remote host linux(10.1.1.2)

Users on Linux100

run

#ssh-keygen -t rsa

results are as follows

Generating public/private rsa key pair.

Enter file in which to save the key (/home/.username/ssh/id_rsa):

Enter passphrase (empty for no passphrase):#Enter

Enter same passphrase again:#Enter

Your identification has been saved in /home/.username /.ssh/id_rsa.

Your public key has been saved in /home/.username /.ssh/id_rsa.pub.

The key fingerprint is:

38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost

Generating RSA keys:

Key generation complete.

Two files, id_rsa and id_rsa.pub, are generated in the user directory ~/.ssh/

Second, copy the id_rsa.pub file on the linux(10.1.1.1) host to the.ssh directory under the root user home directory of the linux(10.1.1.2) host, and rename it authorized_keys.

Namely:

/root/.ssh/authorized_keys

In this way, using the scp command to copy files to linux(10.1.1.2) on linux100 hosts will not prompt for passwords, and will copy directly. And vice versa!

3. Copy file or directory command:

Copy file:

(1) Copy local files to remote

scp filename--user@10.1.1.2: remote path

(2) Copy files from remote to local

scp --user@10.1.1.2: filename local path

Copy directory:

(1) Copy local directory to remote

scp -r directory name--user@10.1.1.2: remote path

(2) Copy the directory back locally from a remote location

scp -r --user@10.1.1.2: Directory name Local path.

After reading the above, do you know how to copy scp between Linux hosts without entering a password? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: File host directory user path password input copy do not use between content command file name method more directory name problem helpless to this end Admiral Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Shulou Technology MySQL Linux