Establish mutual trust when copying files using scp

Source: Internet
Author: User
When the scp command is remotely copied, a password is required for each execution. It is inconvenient if the script automatically backs up or Copies files. At this time, we will use ssh-keygen to Establish a trust relationship between them. Step 1: machine a's ip address is 192.168.1.250, machine B's ip address is 192.168.1.240, and machine a wants to access machine B's scp far

SCpCommandDuring remote replication, a password is required for each execution. If the script is used for automatic backup or file copy, this is inconvenient. At this time, we need to use ssh-keygen to build trust relationships for them. The steps are as follows:

1. Machine a's ip address is 192.168.1.250, machine B's ip address is 192.168.1.240, and machine a wants to access machine B's scp for remote replication without entering a password.

2. principle: Use ssh-keygen on machine B to generate a key pair and place the private key in your home directory. in the ssh directory, copy the key to a (that is, a trusted account that needs to access the machine B without a password), and name the key file authoriz.Ed_ Keys

3. The steps are as follows:
1) generate a key pair on B:
[Root @ test250. ssh] # ssh-keygen-t rsa
Generating public/private rsa key pair.
EnterFileInWhichTo save the key (/root/. ssh/Id_ Rsa): -- press ENTER
Enter passphrase (empty for no passphrase): -- press Enter (indicating that the certificate password is not required)
Enter same passphrase again: -- press Enter
Your identifiCatIon has been saved in/root/. ssh/id_rsa.
Your public key has been saved in/root/. ssh/id_rsa.pub.
The keyFingerPrint is:
12: a1: ac: 45: e6: b9: 1e: 7f: 40: 56: a9:Dd: D9: ea: e1: 2a root @ test250
2) copy the Convention to machine:
[Root @ test250. ssh] # scp id_rsa.pub root@192.168.1.240:/root/. ssh/authorized_keys
Root@192.168.1.240's password:
Id_rsa.pub 100% 394 0.4KB/s
[Root @ test250. ssh] # scp id_rsa.pub root@192.168.1.240:/root/. ssh/authorized_keys
Id_rsa.pub 100% 394
Because there is no trust, you need to enter the user name and password. After copying, the trust relationship has been established.

If you want B to be trusted by a, repeat the preceding steps.
For more help on ssh-keygen, simply use man ssh-keygen.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.