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 does Linux configure keyless login?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to configure keyless login for Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1.ssh command

In linux, you can log in to another server with the ssh command. Open two linux virtual machines, one with an ip of 192.168.226.128 and the other with a linux02 of 192.168.226.129

Enter ssh 192.168.226.129 in the linux01 terminal after boot, and then prompt for the login password of linux02. After entering, you can log in to linux02 on linux01. You can perform command operations, and there are two ways of ssh command.

The ssh ip address (default is root user) logs in as root user

Ssh user name @ ip address to log in as the specified user

two。 Problems solved by key-free login

Now, if you want to log in to the linux02 system on linux01, you need to manually enter the password after the ssh ip address before entering the linux02 server, but after configuring keyless login, you can log in directly by entering the ssh command instead of manually entering the password. Keyless login solves the problem that mutual access between clusters is restricted by passwords. What is a cluster?

Clustering means that many servers do one thing (the servers are connected to each other and can transfer data)

3. Configure keyless login:

As long as the server in the cluster needs to be configured with no key, not only one server can be configured, other machines can use it.

Generate the private key and public key ssh-keygen-t rsa on the server linux01, then click enter four times and do not enter any password, otherwise the key-free fails. You can see the following information configured successfully.

+-- [RSA 2048]-+ | .o. | | .e. | |. . | | o. | | S o. | | o oooo | |. O.Flowers. | | .B. | |. = +. | | +-+

3.2 copy a public key on your own computer and generate one on another server, ssh-copy-id 192.168.226.128, ssh-copy-id 192.168.226.129

This process requires manually entering a password, so that a public key is placed on both the linux01 server and the linux02 server, and keyless login is realized through the public key. You can see the following information configured successfully:

Now try logging into the machine, with "ssh '192.168.23.144'", and check in:

.ssh / authorized_keys

To make sure we haven't added extra keys that you weren't

3.3 configure hostname mapping in hosts of linux01: vim / etc/hosts

Repeat the above steps to configure linux02. If there are multiple servers, copy one on each server when copying the public key, and configure the mapping of each host for ip mapping. Finally, enter the ssh ip address to log in directly without entering a password.

File transfer: scp-r Files / folders to copy destination ip address or hostname: destination folder path

To send the apps folder on linux01 to the home of linux02: scp-r / home/apps 192.168.226.129:/home/ or scp-r / home/apps linux02:/home/

You can transfer the file.

About how to configure keyless login for Linux? So much for sharing here. I hope the above content can help you to some extent and learn more knowledge. If you think the article is good, you can share it for more people to see.

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