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

How to turn off root login in Linux system

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

Share

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

This article introduces the knowledge of "how to turn off root login in Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Turn off direct access to root users and use sudo or su to perform administrator tasks. First, you need to add a new user with root privileges, so edit the sudoers file under this path:

The code is as follows:

/ etc/sudoers/

It is recommended that you use a command such as visudo to edit the file because it checks for any possible syntax errors before closing the file. This is very useful when you make a mistake in editing the file.

Next, give a user root permissions. In this article, the user sysadmin is used. Make sure that the user you use when editing this file is an existing user of the system. Find the following line:

The code is as follows:

Root ALL= (ALL) ALL

Copy this line, paste it on the next line, and change root to "sysadmin", as follows:

The code is as follows:

Root ALL= (ALL) ALL

Sysadmin ALL= (ALL) ALL

Now explain the meaning of each option in this line:

(1) root (2) ALL= (3) (ALL) (4) ALL

(1) specify a user

(2) specify the terminal for which the user uses sudo

(3) specify the user roles that the user can play

(4) commands that this user can use

(note: so the above configuration means that the root user can act as any user on any terminal and execute any command. )

Use this configuration to give users access to some system tools.

At this point, you can rest assured to save the file.

To turn off direct access to root through SSH, you need to open sshd_config again and find the following line:

The code is as follows:

# PermitRootLogin yes

Change to:

The code is as follows:

PermitRootLogin no

Then save the file and restart the sshd daemon to make the changes take effect. Execute the following command:

The code is as follows:

Sudo / etc/init.d/sshd restart

This is the end of the content of "how to turn off root login in Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

*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

Servers

Wechat

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

12
Report