Analysis of Linux configuration to achieve key-free login process

Analysis of Linux configuration to achieve key-free login process

1.ssh command

In Linux, you can log in to another server through the ssh command. Open two Linux virtual machines, one Linux01 with an IP address of 192.168.226.128 and the other Linux02 with an IP address of 192.168.226.129.

After booting up, enter in the linux01 terminal: ssh 192.168.226.129, then you will be prompted to enter the login password of linux02. After entering, you can log in to linux02 on linux01 and perform command operations. There are two ways to use ssh commands

ssh ip address (default is root user) Log in as root user

ssh username@ip address to log in as the specified user

2. Problems solved by keyless 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 to enter the linux02 server. However, after configuring key-free login, you can log in by directly entering the ssh command without manually entering the password. Key-free login solves the problem of password-restricted access between clusters. What is a cluster?

A cluster is a lot of servers doing one thing (the servers are connected and can transfer data)

3. Configure key-free login:

All servers in the cluster need to be configured with a key-free key. It is not enough to configure only one server and then use it on other servers.

3.1 Generate private and public keys on server linux01 ssh-keygen -t rsa , then press Enter four times, do not enter any password, otherwise the key-free function will fail. You will see the following message: Configuration is successful

     +--[RSA 2048]----+
          | .o. |
          | .E. |
          | .. . |
          | o . |
          | S o .. |
          | o oooo |
          | . o.+=. |
          | .B... |
          | .+.=+. |
          +-----------------+

3.2 Copy a public key on your computer and generate a copy on other servers, ssh-copy-id 192.168.226.128 , ssh-copy-id 192.168.226.129

This process requires manual entry of a password once, so that a public key is placed on both the linux01 server and the linux02 server. The public key is used to implement key-free login. The following information is displayed to indicate successful configuration:

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 linux01's hosts: vim /etc/hosts ,

3.4, repeat the above steps to configure linux02. If there are multiple servers, copy the public key on each server. The ip mapping should also be configured for each host. Finally, test that you can log in directly by entering the ssh ip address without entering a password.

File transfer: scp -r File/folder to be copied Target IP address or hostname: Target folder path

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

You can transfer files

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of two ways of Linux service management: service and systemctl
  • Solve the problem of VScode configuration remote debugging Linux program
  • Detailed explanation of the process of configuring multiple SVN repositories on Linux servers
  • Detailed tutorial on uploading and configuring jdk and tomcat on linux
  • Installation and configuration method of Zabbix Agent on Linux platform
  • vscode Linux C++ development code automatic prompt configuration under win10 environment (based on WSL)
  • Summary of Linux environment variable configuration methods (differences between .bash_profile and .bashrc)
  • Install Tomcat on Linux system and configure Service startup and shutdown

<<:  Use Element+vue to implement start and end time limits

>>:  Detailed explanation of basic data types in mysql8.0.19

Recommend

JavaScript implements asynchronous acquisition of form data

This article example shares the specific code for...

Best Practices for Developing Amap Applications with Vue

Table of contents Preface Asynchronous loading Pa...

Basic Implementation of AOP Programming in JavaScript

Introduction to AOP The main function of AOP (Asp...

Some issues we should pay attention to when designing a web page

Web design, according to personal preferences and ...

Example of how to enable Brotli compression algorithm for Nginx

Brotli is a new data format that can provide a co...

Basic principles for compiling a website homepage

1. The organizational structure of the hypertext d...

Several things to note when making a web page

--Homepage backup 1.txt text 2. Scan the image 3. ...

CSS warped shadow implementation code

This article introduces the implementation code o...