Knowledge Base
MilesWeb / Web Hosting FAQ

How to enable Root Login via SSH in Ubuntu

Approx. read time : 3 min

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 Sudo command. But, in some conditions, it is more convenient to directly logged in as root.

Steps to enable Root login over SSH

1) Login 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.

Also Read :

How to Set Up SSH Keys on Ubuntu 18.04

How To Install Chkrootkit Security Scanner On Ubuntu 18.04

Learn to Install PostgreSQL on Ubuntu 18.04

Sonam Wagh
With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.
Need help? We’re always here for you.
Register Your Free Domain Name
OFFER EXPIRES IN
04
min
59
sec