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

The method of SSH secret-free login in Linux

2025-05-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "SSH secret-free login method in Linux". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "SSH secret-free login method in Linux" can help you solve the problem.

Secure Shell (SSH) is an encrypted network protocol that is used for secure connections between clients and servers and supports various authentication mechanisms. Password-based authentication and public key-based authentication are the two most popular authentication mechanisms at present.

1. Purpose

Simplify the SSH login process, from machine A to machine B only need to run ssh hostname, that is, there is no need to enter a user name and password.

two。 Configure host

The function of configuring host is to use hostname instead of IP when ssh logs into the machine. In a cluster environment with many machines, hostname is much easier to remember than IP. Edit the / etc/hosts file, and configure the machines IP and hostname that need to log in. Here, I configure the hostname of machine 129.211.93.219 as spider01.

Vim / etc/hosts

If you can ping the configured hostname, the configuration is successful.

3. Configure secrecy

Use ssh-keygen to generate the key, upload the public key file to the target machine to achieve secret-free login, and use the command to generate the key:

Ssh-keygen-t rsa-C 'comment'-t rsa: specify the use of rsa encryption;-C: add comments, which will be added to the end of the public key file to facilitate identification

Running commands will be entered interactively, and enter directly using the default values. By default, four files will be generated under the .ssh / folder in the home directory:

Authorized_keys: stores the public key of the remote secret-free login, mainly through this file to record the public key of the remote machine. Id_rsa: generated private key file id_rsa.pub: generated public key file known_hosts: list of known host public keys

Then copy the local public key to the target machine through the ssh-copy-id command, and run the command:

Sh-copy-id-I / .ssh/id_rsa.pub user_name@hostname

After running successfully, you can log in with ssh user_name@hostname password-free.

4. Configure user-free

Edit the config file under the .ssh / directory. If not, create a new one.

Vim / .ssh/config

Add the target machine configuration:

After the addition is successful, you can log in directly using ssh hostname.

This is the end of the introduction of "the method of SSH secret-free login in Linux". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

*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

Development

Wechat

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

12
Report