Requirements: There are 3 hosts 192.168.0.191, 192.168.0.192, 192.168.0.193, need to implement password-free SSH internet access
I'm using the root user to do this:
1, each node checks whether to install OpenSSH (each node does): If you do not have SSH installed, you need to install, execute the command:
sudo Install SSH
2. Generate the public and private keys for each node separately:
Ssh-keygen -t RSA
After the execution of the above command, 3 times to enter the line, where-T after the parameter refers to the type of encryption protocol used, can be RSA or DSA, the generated public key file is ~/.ssh/id_rsa.pub, the private key file is ~/.ssh/id_rsa, we use a public key file.
3. Perform a public key copy on each node:
Cat ~/. ssh/id_rsa.pub >> ~/. ssh/authorized_keys
4, the other node's id_rsa.pub also adds the public key to this node and then distributes it to the other nodes "that is, public key merge after sharing":
I was merging on the 192.168.0.192 node, so I executed the command in turn on the 192.168.0.192:
SSH 192.168.0.193 Cat~/.SSH/id_rsa.pub >> ~/.SSH/Authorized_keysSSH 192.168.0.191 Cat~/.SSH/id_rsa.pub >> ~/.SSH/Authorized_keysSCP~/.SSH/authorized_keys192.168.0.193:~/.SSH/Authorized_keysSCP~/.SSH/authorized_keys192.168.0.191:~/.SSH/authorized_keys
In the above command, when you finish 2nd, you can view the Cat ~/.ssh/authorized_keys view file, the file content has become 3 lines, that is, contains 3 nodes of the public key.
5. Testing
I tested it on 192.168.0.192, and I first set up a file ~/hello.txt on the 192.168.0.193.
SSH 192.168. 0.193 ls ~
At this point, you don't need to enter a password to see the file you just created. You can try multiple ssh between the remaining nodes, and the result is the same.
Implementation of multi-node SSH without password interconnection under Linux