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 realize two-way password-free login in CentOS

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

CentOS how to achieve two-way password-free login, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Principle:

(here two machines are represented by host 1 and host 2, and here the two machines are equivalent.)

If host 1 wants to log in to host 2 without a password, host 2 needs to be able to identify itself, which is identified by public and private keys.

Generate the public key and private key on host 1 and pass its public key to host 2, so that when host 1 logs in to host 2, host 1 can use the private key to let host 2 know itself.

Action:

-premise:

The following three lines of all server / etc/ssh/sshd_config files are not commented

RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh / authorized_keys

For example:

Two servers: 192.168.1.100

192.168.1.102

Password-free login is user-specific. Take the root user as an example. The .ssh directory is under each user's home directory.

-steps:

Log in to 192.168.1.100.

Execute the command "ssh-keygen-t rsa" and enter all the way to the end. The private key id_rsa and public key id_rsa.pub will be generated under the directory / root/.ssh/.

Append the local public key id_rsa.pub to the authorized_keys file of 192.168.1.102.

At this time, you don't need a password to log in from 192.168.1.100 to 192.168.1.102.

To achieve bidirectional, continue with the following steps:

Log in to 192.168.1.102 and perform the similar steps above.

-Note:

You need to restart the sshd service after modifying the / etc/ssh/sshd_config file

Append the public key to the server's authorized_keys and never overwrite it.

The .ssh directory has permissions of 700 authorizedauthorized keys and 600 permissions.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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: 300

*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