Do it your self hobby code

How to disable root access — Ubuntu

To add another layer of security on your Ubuntu server, we have to disable root access to avoid your server exposed to a brute force attack.

Before doing this, first you should have a sudo user account.

Disabling the root access:

sudo nano /etc/ssh/sshd_config

Change PermitRootLogin from yes to no:

PermitRootLogin no

Now save the changes by pressing ctrl+o and exit with ctrl+x

Finally, restart the ssh service

sudo service ssh restart

That’s it. You have now disable the root access. As a result, you cannot login directly using root, but still you can switch to root once you have logged in using another username.

Below it the command for switching to root:

su root

Leave a Comment

Your email address will not be published.