Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does scp copy between Linux hosts without entering a password?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report