Detailed explanation of the idea of ​​xshell remote login to CentOS7 without password login

Detailed explanation of the idea of ​​xshell remote login to CentOS7 without password login

First, let me talk about the general idea:

1. Log in to the CentOS system with a password

2. Configure ssh

3. Generate a secret key using xshell

4. Log in without password

Software and equipment:

xshell (download address (free version), you can also download it from Baidu)

CentOS7.5 (Baidu Cloud Server)

Now let’s get back to the point:

1. Password remote connection CentOS

Open xshell -- File -- New, and the following interface will pop up

Explain what needs to be modified.

Name: To distinguish the server, you can give it any name. Protocol: SSH is the default. Host: The IP address of the machine where the CentOS system is located. Port: 22 by default. You can reconnect: If necessary, you can check it. When the connection is accidentally disconnected, xshell will automatically reconnect.

Select <User Authentication> in the directory on the left, and the following interface will be displayed

Parameter Description:

Method: The verification method when xshell connects to CentOS. For the first time, select Password Username: CentOS username. I use the root account password directly here: The password of the login account is required

Then connect. If you successfully log in, your logged-in username will be displayed in front of the command line, as shown in the figure below.

If the login fails, first check whether the login account exists and whether the password is correct. If there is no problem, check whether the CentOS port is open.

2. Install and configure ssh

1. Install openssh-server

yum install -y openssl openssh-server

2. Modify ssh configuration

Open /etc/ssh/sshd-config using vim

sudo vim /etc/ssh/sshd_config

After editing, save

3. Start the ssh service

systemctl start sshd.service

4. Set ssh to start automatically at boot

systemctl enable sshd.service

5. Create .ssh folder

Create a .ssh folder in the user's home directory

mkdir ~/.ssh

So far, the ssh configuration has come to an end

3. Generate a secret key using xshell

1. Open xshell -- Tools -- User Key Manager

The following window will pop up

Select Generate in the right row of options

Select Next, no modifications are required

The key has been generated, click Next

Parameter Description

Key name: any name you can give it Password: this is the password to verify our identity, it will be encrypted by RSA, here I use 123456 Confirmation: the same as the password above, the purpose is to check whether our two passwords are consistent

Click Next and the following figure will pop up.

Then select Save File to save the public key information. Here I save it as test.pub. After saving, click Finish (xshell will automatically record test.pub)

Then upload test.pub to the .ssh folder we created in step 2

Here I use the rz command (install yum install -y lrzsz, file transfer command)

First, cd ~/.ssh to enter the .ssh folder, then execute rz, a window for selecting files will pop up, select the test.pub file you just generated

Then use ll to check whether the upload is successful

Finally, add the public key in test.pub to authorized_keys (authorized_keys stores public keys)

cat test.pub >>authorized_keys

4. xshell sets up password-free login

Create a new connection and set the name, host, port and other information in the same way. Note that the name should be set differently to facilitate differentiation.

Setting up user authentication

Parameter Description:

  • Method: Select Public key
  • Username: The user who created the .ssh folder. I am the root account here, so the username is root
  • User key: Select test in the drop-down box (the test.pub just created)
  • Password: This is the password you entered when generating the key.

Then connect and you can log in without password.

Summarize

The above is a detailed explanation of the idea of ​​xshell remote login to CentOS7 without password login introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Centos7 network configuration details
  • CentOS7 network configuration under VMware virtual machine (host wireless Internet access)
  • CentOS7 network configuration tutorial under VirtualBox (can connect to the external network)
  • How to connect XShell and network configuration in CentOS7

<<:  Vue realizes picture switching effect

>>:  Summary of MySQL development standards and usage skills

Recommend

How to set up Referer in Nginx to prevent image theft

If the server's images are hotlinked by other...

Design Theory: A Method to Understand People's Hearts

<br />Once, Foyin and Mr. Dongpo were chatti...

Optimize MySQL with 3 simple tweaks

I don't expect to be an expert DBA, but when ...

Vue3 encapsulates its own paging component

This article example shares the specific code of ...

Three solutions for sub-functions accessing external variables in JavaScript

Preface When we write web pages, we will definite...

Detailed explanation of reduce fold unfold usage in JS

Table of contents fold (reduce) Using for...of Us...

js implements the pop-up login box by clicking the pop-up window

This article shares the specific code of js to re...

CSS mimics remote control buttons

Note: This demo is tested in the mini program env...

Implementation steps for Docker deployment of SpringBoot applications

Table of contents Preface Dockerfile What is a Do...

mysql5.6.8 source code installation process

Kernel: [root@opop ~]# cat /etc/centos-release Ce...

How to encapsulate axios in Vue project (unified management of http requests)

1. Requirements When using the Vue.js framework t...

MySQL Flush-List and dirty page flushing mechanism

1. Review The Buffer Pool will be initialized aft...