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 disable the root account by Linux

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

Share

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

This article is about how Linux can disable root accounts. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In order to ensure the security of the Linux system, we should try to avoid using the root account directly, so we can consider disabling the root account to prevent cracking and login.

First log in to the system using a root account, add a regular account such as test, and set a password for it

Useradd test passwd test

Edit the configuration file / etc/ssh/sshd_config to change the yes after PermitRootLogin to no, and remove the previous comment character

Finally, restart the sshd service / etc/init.d/ssh restart or service sshd restart, and then log in with the root user. If you cannot log in, the configuration is successful. If you need to use root permissions, you can use su/sudo to switch

The following is a detailed supplement:

The default administrator name for Linux is root, and you only need to know the ROOT password to log in to SSH directly. Preventing Root from logging in directly from SSH can improve server security. It can be realized after the following operations.

This paper is suitable for CentOS, Debian and other Linux systems.

I. create a new account

Useradd kwxgd

SSH executes the above command to create an account named "kwxgd" that can be customized.

Second, set the account password

Passwd kwxgd

Use the passwd command to set or change the password for the appropriate account.

According to the figure, you need to fill in the password twice to set or change the password, and the second time is the valid password. Please enter and confirm after entering.

Third, root is not allowed to log in directly

1. Modify related documents

Vi / etc/ssh/sshd_config

SSH executes the above command to modify the sshd_config file

2. Disable root login

Look for "# PermitRootLogin yes", remove the previous "#", change the short tail "Yes" to "No", and save the file.

3. Restart the sshd service will take effect.

# service sshd restart

Fourth, log in next time

1. First use the new account "kwxgd" to log in as ordinary users.

2. To get ROOT permission, execute the following command in SSH

Su root

After executing the above command and entering the root password, you can gain root permission.

Thank you for reading! This is the end of the article on "how to disable the root account in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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