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

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

Or

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

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.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna