Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting FAQ  >  How to enable Root Login via SSH in Ubuntu
Top Scroll

How to enable Root Login via SSH in Ubuntu

 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

vim /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.

PermitRootLogin yes

4) Save this file and exit.

5) Restart your SSH server using the following command :

systemctl restart sshd


service sshd restart

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 :

PermitRootLogin without-password

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

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.