0

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?

Craig
  • 145
  • 1
  • 1
  • 6

1 Answers1

1

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

golder3
  • 126
  • 3
  • Bang on. I just removed the hashtag. With that being said, I never had to remove the hashtag, when using Debian. – Craig Feb 02 '22 at 22:30