There are two virtual machines with centos installed on two laptops. you need to set up ssh password-free login. The steps are as follows:
I have two virtual machines with centos installed on my laptop. one IP address is 172.16.1.10 (slave) and the other IP address is 172.16.1.9 (master ).
Use the root user vi/etc/hosts on slave to add the 172.16.1.9 master.
1. run the following command on slave:
Copy codeThe code is as follows:
Ssh-keygen-t rsa or ssh-keygen-t rsa-p''
-P indicates the password.-P ''indicates that the password is empty, or you do not need the-P parameter. in this case, you have to press enter three times and press enter once with-P.
It is in ~ The. ssh directory is generated under the Directory, and id_rsa and id_rsa.pub under. ssh.
2. execute the scp Remote Copy command on the slave:
Copy codeThe code is as follows:
Scp ~ /. Ssh/id_rsa.pub
Because no password-free login is set at this time, you need to enter the password for remote copy.
(Scp command format:
Copy codeThe code is as follows:
Scp local_file
3. run the following command on the master:
Copy codeThe code is as follows:
Cat ~ /Id_rsa.pub> ~ /. Ssh/authorized_keys
Append the public KEY to the authorization KEY.
4. run the following command:
Copy codeThe code is as follows:
Chmod 600 ~ /. Ssh/authorized_keys
The authorized_keys permission is 600.
Now the server load balancer can use ssh master.
Summary: The logon host has a private key, and the logged-on host must have a public key. This public/private key pair is generally generated on the host machine of the private key. The above is a public/private key pair using the rsa algorithm. of course, you can also use dsa (the corresponding file is id_dsa, id_dsa.pub)
If you want A and B to log on to each other without A password, configure the same method as above.