How to enable and disable SSH access to the Root account

A few weeks ago I offered you a tutorial for enable SSH on Windows

In this tutorial I will explain to you how to enable SSH access or disable SSH access for the Root account.

As you can imagine, we’re going to talk about Linux systems like Debian or Ubuntu.

Small reminder on SSH

When you order a dedicated server or VPS from a provider such as OVH or Ionos, we provide you with SSH connection information by email.

SSH allows you to connect securely to your servers. Once logged in you can enter commands to interact with your server.

Finally, most of the time we use the free Putty tool to make the connection.

putty window for ssh connection

Disabling and Enabling SSH access for the Root account

Disabling the SSH service for the Root account allowsincrease access security on your server.

The Root account is an account that exists on all Linux operating systems, so robots can do connection attempts with the Root account.

Enable SSH access for the Root account

You must be connected in SSH with an account other than the Root account (ovh sends you a connection account by email). You can then switch to Administrator with the following command

sudo su -

You will then be prompted for the account password.

In administrator mode you can define a “root” password by entering the following command:

passwd root

Once connected we will use thetool vi to modify configuration files. VI is a command line file editor, here we will modify the sshd_config file

vi /etc/ssh/sshd_config

For beginners it can be complicated to use, we will move with the arrows on the keyboard and add the following parameter to the file.

PermitRootLogin Yes

For save and exit you must enter the following command:


The file is modified, to apply the change you must restart the SSH service:

systemctl restart ssh

Disable SSH access for the Root account

To deactivate the Root account, all you have to do is re-edit the sshd_config file with the VI tool.

Except that instead of putting “PermitRootLogin Yes, you must set the parameter to No

PermitRootLogin No

And we have to restart the SSH service.

Try to connect in SSH with the “root” account, logically you cannot open sessions.

Related Articles

Leave a Reply

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

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker