How to Disable Root User Login in Linux 


               


How to Disable Root User Login in Linux



Linux


In this article, we show how to disable root user login in Linux.

The root user can be a dangerous thing in systems. The root user is very powerful and the root user has the most privileges out of all users.

Therefore, many times, programmers will create another user or users and disable root user login. This gives some protection for the system.

So before you disable root user login for a system, you should create another user and typically you should grant this user sudo privileges. This is so that you have a user that can perform some administrative tasks in linux using the sudo commands.

Once you have another user created other than the root user and this user has been given sudo privileges, then you can look to disable root user login in linux.

So how do we disable root user login in linux?

So in the command terminal, you enter in the following line.



So after you enter in the line above in the linux command terminal, you will see a whole bunch of configurations appear on the screen.

Know that SSH configurations stands for Secure Shell configurations. SSH is the system in how users log into a linux terminal. We are adjusting these settings now so that we do not permit root user login.

How we do this is we look for the attribute, PermitRootLogin

If you find this line, you will see that by default, it is set equal to True (PermitRootLogin=True).

Scroll your cursor to this attribute and delete, 'Yes', and type in, 'No'

This is shown below.


Disabling root user login in linux with the PermitRootLogin attribute


Once you have changed the PermitRootLogin attribute to 'No', then press Ctrl+X to exit out of this SSH configuration settings.

The command terminal will then ask you if you want to save the changes you have made. You enter in 'Y' for yes.

You will then see the line, File Name to Write: /etc/ssh/sshd_config

You then press enter and you should brought back to the regular screen of the user you were logged in as.

We have now disabled root user login.

This means that we cannot log in as the root user. For example, if we're using the program, Filezilla, in order to access the remote server that we use as a hosting company, we won't be able to do so as the root user. We must log in as another user for the system.

Again, this gives a good amount of security protection for the system, as having root user login can be dangerous.

And this is how to disable root user login in linux.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...