How to Enable or Disable SSH Root Login Access in Ubuntu?

27-Jun-2023

.

Admin

How to Enable or Disable SSH Root Login Access in Ubuntu?

Hello Friends,

In this article we will cover how to implement how to enable or disable ssh root login access in Ubuntu. This tutorial will give you a simple example of enabling/disabling ssh root login on Ubuntu. Here you will learn to enable/disable root login via ssh in Ubuntu. I want to share with you how to enable or disable ssh root login in linux.

SSH root user login access is not enabled by default on any system. During system installation, you are asked whether you want to enable or disable SSH root user login access. However, suppose you are unsure how to enable or disable it. In that case, this tutorial will guide you through the process of enabling and disabling SSH root user login access from the command line.

Disable SSH Root Login


If SSH root user login access is enabled in your system and you do not know how to disable SSH root user login. So you can disable root user login access using the following commands.

First of all, open the terminal and execute the following command into it to open the main ssh configuration file /etc/ssh/sshd_config:

vi /etc/ssh/sshd_config

In the file opened with the upper command, search for the following line:

#PermitRootLogin no

Remove the ‘#‘ from the beginning of the line. Make the line look similar to this:

PermitRootLogin no

After that restart your server. So that is what you have changed in your file. It makes changes done:

# systemctl restart sshd

OR

# /etc/init.d/sshd restart

After all, you’ve now disabled the SSH root user login. You will no longer be able to access the root user login. You can also see this by trying it.

When you try to log in with the root user, Denied will be displayed in your terminal. Why have you disabled your root user login access?

Enable SSH Root Login

If SSH root user login access is disabled in your system and you do not know how to enable SSH root user login. So you can enable root user login access using the following commands.

Now, open the terminal and execute the following command into it to open the main ssh configuration file /etc/ssh/sshd_config:

vi /etc/ssh/sshd_config

In the file opened with the upper command, search for the following line:

#PermitRootLogin yes

Remove the ‘#‘ from the beginning of the line. Make the line look similar to this:

PermitRootLogin yes

After that restart your server. So that is what you have changed in your file. It makes changes done:

# systemctl restart sshd

OR

# /etc/init.d/sshd restart

After all, you’ve now enabled the SSH root user login. You will be able to access the root user login. You can also see this by trying it.

When you try to log in with the root user, The Access grant will be displayed in your terminal. Why have you enabled your root user login access?

I hope it can help you...

#Ubuntu