Search Our Database

How to disable root access in CentOS?

Last updated on |
by

It is not advisable to use your root account regularly as such, we recommend you disable root access but not before you learn how to create a user account with root privileges. Read the tutorial: How to create a user with root privilege.

Step 1 – Login into your web server via SSH.

Step 2 – Open the main SSH configuration file /etc/ssh/sshd_config by running the following command:# vi /etc/ssh/sshd_config

# vi /etc/ssh/sshd_config

Step 3 –  Search for the following line in the file:

# PermitRootLogin no

Step 4 – Remove the ‘#‘ from the line to resemble below:

PermitRootLogin no

Step 5 – Restart the SSH daemon service:

# /etc/init.d/sshd restart

You are now unable to login to your root account and will see the “Access Denied” error message when you attempt to login; login with the newly created user account instead.