Disable direct root login on your server

To increase server security you can disable direct root login. We will create a wheel user. You will connect first with this user and then you will use the su command to switch to the root user.

The necessary steps are:

1. Create a new CentOS user using the command:

adduser username

2. Set a password for the created user with:

passwd username

3. Add the user to the Wheel Group. For this, run the command:

usermod -aG wheel username

4. Edit the /etc/ssh/sshd_config file:

nano /etc/ssh/sshd_config

Add the line (or modify if it is PermitRootLogin yes)

PermitRootLogin no

Save the file and exit the file editor.

5. Restart the SSH server:

service sshd restart

Also check our KB post on how to Create and remove CentOS users

Leave a Reply