Score:0

How to disable Root Access, to VPS, via SSH?

pt flag

I run a VPS, on a Linux Server, with CentOS 7 (64 bits) being the chosen Operating System.

I have recently wiped the VPS, so it only has a clean install of Plesk Onyx at the moment. I would now like to disable root access to the VPS, via SSH, prior to setting up domains and emails.

To achieve this, I gained SSH access, via the PuTTY Terminal. Using the Nano Text Editor, I entered the following Command Line:

# nano /etc/ssh/sshd_config

This opened up the correct file, where I then changed the #PermitRootLogin entry from 'yes' to 'no'; as per the following screenshot:

enter image description here

I was able to save and exit the file. I also was able to see that the changes were indeed saved, upon accessing the file again.

I am aware that in order for such changes to take place, the SSH Service needs restarting. To do this, I have tried the following command lines (Individually):

# service ssh reload
# sudo systemctl restart sshd.service
# sudo systemctl restart sshd
# sudo systemctl restart sshd.service

None of the above command lines, confirmed whether or not SSH was restarted. Regardless, I am still able to log into SSH using the root credentials.

Is anyone able to identify where I could be going wrong?

Score:1
jp flag

In many configuration files commented lines show you the default values, like in your sshd_config file:

#PermitRootLogin yes

You need to change to no AND delete # to un-comment the line

PermitRootLogin no

As for the systemctl, and many other commands, if it doesn't return anything it means that the command was successful

Craig avatar
pt flag
Bang on. I just removed the hashtag. With that being said, I never had to remove the hashtag, when using Debian.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.