Disable SSH Login for the Root User on CentOS / RHEL
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:
3. Remove the hashtag sign (#). After doing this, it should look like this:
Now we need to restart the SSH daemon service. Here are the commands to restart SSH daemon service:
That’s all. Now you’re unable to login with root account. ?
sudo systemctl restart sshd # Or, sudo service sshd restart # Or, sudo /etc/init.d/ssh restart
Preview may take a few seconds to load.
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Bold **double asterisks**
Three back ticks and then enter your code blocks here.
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
> type a greater than sign and start typing your quote.
You can add links by adding text inside of  and the link inside of (), like so:
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of , and the image URL inside of (), like so:
To add a divider you can add three dashes or three asterisks:
--- or ***