Implementation of multi-node SSH without password interconnection under Linux

Source: Internet
Author: User
Tags free ssh

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

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.