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

How to insert pictures into HTML pages and add map index examples

1. Image formats supported on the WEB: GIF: can s...

linux exa command (better file display experience than ls)

Install Follow the README to install The document...

How to build your own Nexus private server in Linux

This article describes how to build a Nexus priva...

Specific use of Linux which command

We often want to find a file in Linux, but we don...

Vue calls the PC camera to realize the photo function

This article example shares the specific code of ...

File sharing between Ubuntu and Windows under VMware

This article records the method of sharing files ...

Detailed explanation of adding click event in echarts tooltip in Vue

Table of contents need Workaround 1. Set tooltip ...

Sample code for implementing interface signature with Vue+Springboot

1. Implementation ideas The purpose of interface ...

Clever use of webkit-box-reflect to achieve various dynamic effects (summary)

In an article a long time ago, I talked about the...

Detailed explanation of Tomcat's commonly used filters

Table of contents 1. Cross-domain filter CorsFilt...

CSS inheritance method

Given a div with the following background image: ...

Summary of 3 ways to lazy load vue-router

Not using lazy loading import Vue from 'vue&#...

Detailed explanation of Linux system directories sys, tmp, usr, var!

The growth path from a Linux novice to a Linux ma...

Solution to VMware virtual machine no network

Table of contents 1. Problem Description 2. Probl...