How to Enable Root Login via SSH in Ubuntu Print

  • enable Root Login, Root, Ubuntu, sshd_config, SSH
  • 7

SSH on Ubuntu is by default configured in a way that disables the root users log in. Originally this is enabled as a security measure which means that you cannot directly log in as the root user over SSH. However, you can easily use the Root SSH login via the Sudo command. But, in some conditions, it is more convenient to directly logged in as root.

Steps to enable Root login over SSH

1) log in to your server as root.

2) Now you are a root user. So, edit the sshd_config file located in /etc/ssh/sshd_config

3) Now, add the following command to the file. Even though you can add it anywhere but we advise you to follow the best practice by adding the command in the block for authentication.

4) Save this file and exit.

5) Restart your SSH server using the following command :

Or

That’s it.

With this, the new line gets added and the SSH server gets restart, this allows you now to connect via the root user.

In this instance, you will be able to log in as the root user by using either the password or an SSH key.

If you use SSH keys, you will be able to set the PermitRootLogin value to ‘without-password’ instead of yes. To complete this, just modify step 2 with the following command :

This process works on all versions of the Linux server on which the sshd service is installed. In case you are using a cPanel server, still you can easily control this setting from the WHM interface. In such cases, we recommend you to modify this setting from your control panel interface.


Was this answer helpful?

« Back