Linux system prohibits remote login command of root account

Linux system prohibits remote login command of root account

ps: Here is how to disable remote login of root account in Linux system. The details are as follows:

Modify the configuration file /etc/ssh/sshd_config, remove the comment before PermitRootLogin, change the value to no, and then restart the sshd service.

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
MaxAuthTries 3
#MaxSessions 10
service sshd restart

After performing this operation, the root account will not be able to log in remotely, so you must create a new account and set a password before doing this.

useradd xiaowen
passwd xiaowen

ps: Let's take a look at disabling root remote login and adding new users under Linux

1. Add a user with the same permissions as root

1.

adduser admin

passwd admin (change password)

Then enter the password (a simple password will not work)

The system prompts you to enter a confirmation password and then enter it again. OK Added successfully.

2. Modify the /etc/sudoers file, find the following line, and add a line below root as follows:

vim /etc/sudoers 
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
admin ALL=(ALL) ALL

This file is read-only as a protection mechanism. If you use the vi editor, just use :wq! to save it. Or use the visudo command to enter the sudoers file editor and save it normally

1) Single-line copy In command mode, move the cursor to the line to be copied and press "yy" to copy;
2) Copy multiple lines In command mode, move the cursor to the first line to be copied and press "nyy" to copy n lines; n is 1, 2, 3, etc.
2. Paste in command mode, move the cursor to the line where you want to paste, and press "p" to paste

2. Disable root remote login

You need to edit /etc/ssh/sshd_config.

vim /etc/ssh/sshd_config find PermitRootLogin

Change to PermitRootLogin no

Restart service sshd restart

Conclusion:

This will prohibit the root user from logging in and log in with admin. It's so complicated for safety.

You only banned the root user from logging in, not other users. Log in with another user first, then switch back to the root user with su root

Switch to the root user and enter the password

Summarize

The above is the command that I introduced to you to prohibit remote login of the root account in the Linux system. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time!

You may also be interested in:
  • Solution to the problem that FTP account cannot delete folders in Linux
  • Detailed explanation of Linux account management
  • The Linux SVN server supports both Apache http and svnserve standalone server modes and uses the same access permission account
  • How to create a new mysql account and set permissions under Linux
  • Detailed steps for Linux account file control management

<<:  MySQL 8.0.11 Community Green Edition Installation Steps Diagram for Windows

>>:  Django+vue registration and login sample code

Recommend

vue3+ts+EsLint+Prettier standard code implementation

Table of contents use Use of EsLint Add a profile...

MySQL Series 7 MySQL Storage Engine

1. MyISAM storage engine shortcoming: No support ...

Implementation of Nginx+ModSecurity security module deployment

Table of contents 1. Download 2. Deployment 1.Ngi...

javascript realizes 10-second countdown for payment

This article shares the specific code of javascri...

Deploy Confluence with Docker

1. Environmental requirements 1. Docker 17 and ab...

Implementation of Single Div drawing techniques in CSS

You can often see articles about CSS drawing, suc...

Implementation steps of encapsulating components based on React

Table of contents Preface How does antd encapsula...

Usage instructions for the docker create command

The docker create command can create a container ...

Detailed tutorial on deploying Django project using Docker on centos8

introduction In this article, we will introduce h...

Pure CSS to achieve cool neon light effect (with demo)

I have recently been following the CSS Animation ...

Uniapp uses Baidu Voice to realize the function of converting recording to text

After three days of encountering various difficul...

How to use multi-core CPU to speed up your Linux commands (GNU Parallel)

Have you ever had the need to compute a very larg...

A brief talk about calculated properties and property listening in Vue

Table of contents 1. Computed properties Syntax: ...

JavaScript simulation calculator

This article shares the specific code of JavaScri...

Join operation in Mysql

Types of joins 1. Inner join: The fields in the t...