How to Disable Root Access on a Server?
Root access on a server is one of the most vulnerable points that attackers can exploit to compromise your system. Therefore, it is important to take steps to disable it and establish more secure alternatives for server administration. In this article, we’ll explore how to do it.
The first step to disabling root access on the server is to create a new user with superuser privileges. To do this, run the following command in the terminal:
sudo adduser newuser
After creating the new user, you need to add them to the sudoers group so they have the rights to perform administrative tasks. To do this, run the following command:
sudo usermod -aG sudo newuser
Then, you need to switch to the new user and check their permissions. To do this, execute the following commands:
su - newuser
sudo -l
If the new user’s permissions meet your requirements, you can proceed to disable root access. To do this, run the following command:
sudo passwd -l root
After completing all these steps, root access on the server will be disabled, which will increase the security of your system. Remember to save access to the new user and ensure they have the necessary permissions to administer the server.