Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure SSH without password authentication

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to configure SSH without password authentication". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to configure SSH without password authentication".

Enter the second machine and take a look at the IP address of this host:

You can see that the IP address of this host is 192.168.184.131.

We changed the host name to "Slave1" in / etc/hostname:

Save exit.

In order for the changes to take effect, we restart the machine and look at the hostname at this time:

It shows that our changes have taken effect.

Enter the third machine and take a look at the IP address of this host:

You can see that the IP address of this host is 192.168.184.132.

We changed the host name to "Slave2" in / etc/hostname

Save exit.

In order for the changes to take effect, we restart the machine and look at the hostname at this time:

It shows that our changes have taken effect.

Now, the corresponding relationship between hostname and IP address is configured in / etc/hosts on Slave1. When opened:

At this point, we modify the configuration file to:

Configure the correspondence between the hostname and IP address of "Master" and "Slave1" and "Slave2". Save exit.

At this point, we ping the Master node and find that there is no problem with network access:

Next, configure the correspondence between the hostname and the IP address in / etc/hosts on Slave2, as follows:

Save exit.

At this point, we ping Master and Slave1 and find that we can communicate with ping.

Finally, configure the corresponding relationship between hostname and IP address in / etc/hosts on Master as follows:

At this point, use the ping command on Master to communicate with the Slave1 and Slave2 machines:

It is found that the machines of the two slave nodes have been connected to ping at this time.

Finally, we are testing the communication between Slave1 and Master and Slave2:

So far, Master, Slave1, and Slave2 have communicated with each other!

Step 2:SSH no password authentication configuration

First, let's take a look at how Master accesses Slave1 through the SSH protocol without configuration:

At this point, we will find that we need a password. We don't log in, we just exit.

How to enable the cluster to use the SSH login-free password?

According to the previous configuration, we have generated a private key id_rsa and a public key id_rsa.pub under the / root/.ssh/ directory on the Master, Slave1, and Slave2 machines.

At this point, pass the id_rsa.pub of Slave1 to Master, as follows:

At the same time, pass the id_rsa.pub of Slave2 to Master, as follows:

Check on Master to see if it has been copied:

At this point, we find that the public keys of the Slave1 and Slave2 nodes have been transferred.

Synthesize all public keys on the Master node:

Copy the public key information authorized_keys of Master to the .ssh directory of Slave1 and Slave1:

Log in to Slave1 and Slave2 again through SSH:

At this point, it is no longer necessary for Master to log in to Slave1 and Slave2 through SSH, and the same Slave1 or Slave2 to log in to the other two machines through SSH protocol.

Step 3: modify configuration files for Master, Slave1, and Slave2

At this point, I believe you have a deeper understanding of "SSH password-free authentication how to configure", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report