What are we doing?
- Setting a password for the root user
- Enabling login with SSH for root user
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!
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
Comment it out by prefixing a # as below
Below this line, add the following, new line
ctrl + x then y followed by return to save and exit
sudo service ssh restart
Disabling the root account
sudo passwd -dl root
Then undo the above changes to /etc/ssh/sshd_config