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 enable root permission and disable root account by ubuntu

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

Share

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

This article mainly introduces ubuntu how to open root permissions and disable root accounts. The article is very detailed and has a certain reference value. Interested friends must finish reading it!

Newly installed ubuntu cannot use root by default. We need to open it manually.

Enter in the terminal:

Sudo passwd rootEnter new UNIX password: (enter your password here) Retype new UNIX password: (confirm the password you enter) passwd: password updated successfully

Later, if you want to get root permission again, you only need to do the following:

Su rootPassword: (enter the password you set above)

If you want to disable the root account again

Then it can be executed.

Sudo passwd-l root

The permissions of ROOT users are unlimited, but sometimes we disable some functions of ROOT users for some security needs. Let's take a look at an article in Linux about how VPS forbids ROOT to authorize / login / disable root users.

Modify the idea of ROOT: add a new user, and then set the user to ROOT permission, so that we can log in to SSH and use the new user, which is only known to us, which increases the difficulty of guessing, and the security of the VPS host is further improved.

First, add new users and set passwords

Useradd itbulucom

Passwd itbulucom

Use useradd to add a user, passwd sets a password for this user, and then the add password interface appears. We enter the password and enter it again.

Add new administrative users

Second, set permissions

Vi / etc/ssh/sshd_config

You can use the above vi command to open the sshd_config file to modify the configuration, find PermitRootLogin and change the parameter yes to no, and then save and exit.

Third, restart the SSH settings

# centos

/ etc/init.d/sshd restart

# debian/ubuntu

/ etc/init.d/ssh restart

According to the different choices of our own system, it corresponds to the restart SSH command. After the restart, we cannot log in with ROOT. We must use the newly set itbulucom and password to log in to SSH. If you don't believe me, you can try.

Supplementary prohibition of direct login of root account

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.

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.

A safer approach is to disable the ROOT account

The first step is to log in to VPS with SSH.

Useradd laozuo # add user name

Passwd laozuo # set the password for the laozuo username

Then you need to enter the password twice, and you will see the display shown in the picture.

Disable ROOT account

The second step is that we need to set to disable ROOT users, which needs to compile the file. We can operate through the VI command, or we can download and edit files through FTP software such as WINSCP.

Vi / etc/ssh/sshd_config

As with the previous setting port, compile the sshd_config file and change the YES in PermitRootLogin to NO

Modify PermitRootLogin

Save exit and restart SSH:service sshd restart (centos) / service ssh restart (debian)

The third step is to increase the power. Log in with our newly added user name, and then su root elevates the rights, so that new users have the highest privileges of ROOT users.

The above is all the contents of the article "how to enable root permissions and disable root accounts by ubuntu". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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