Enable SSH Login for Linux root User

 

What are we doing?

  • Setting a password for the root user
  • Enabling login with SSH for root user

 

Why?

Root login is disabled by default on Ubuntu (and many other Linux distributions) as it is rarely required. For day-to-day tasks, sudo or logging in as normal, then changing session owner via su is preferred.

There are, however, a few rare situations where direct login as root is required. For example, my recent need for it came when using VMware’s vCenter Converter to convert a Linux box to a vSphere virtual machine.

It is not recommended to apply the information in this guide for any longer than required!

How?

Login via SSH

To enable the root account

sudo passwd root

Enter and confirm a password (the password will not show as you type)

To enable root login via SSH

sudo nano /etc/ssh/sshd_config

Find the following line

PermitRootLogin without-password

Comment it out by prefixing a # as below

#PermitRootLogin without-password

Below this line, add the following, new line

PermitRootLogin yes

ctrl + x then y followed by return to save and exit

Restart SSH

sudo service ssh restart

 

Disabling the root account

 

sudo passwd -dl root

Then undo the above changes to /etc/ssh/sshd_config

Leave a Reply

Your email address will not be published. Required fields are marked *