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.