Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Disable SSH Login for the Root User on CentOS / RHEL

Published on September 8, 2019 24 sec read

In this short article, I’ll show how to disable SSH root login on CentOS / RHEL server. Let’s see:

Note: You should create a user with root access before doing this.

1. Open SSH configuration file using this command:

sudo nano /etc/ssh/sshd_config

2. Search for the following line in the SSH configuration file:

#PermitRootLogin no

3. Remove the hashtag sign (#). After doing this, it should look like this:

PermitRootLogin no

Now we need to restart the SSH daemon service. Here are the commands to restart SSH daemon service:

sudo systemctl restart sshd
# Or,
sudo service sshd restart
# Or,
sudo /etc/init.d/ssh restart
That’s all. Now you’re unable to login with root account. 🙂

You're welcome to suggest any article to write!

Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Leave a Reply

Your email address will not be published. Required fields are marked *