Tutorials Allow SSH root login on Ubuntu 20.04 Focal Fossa Linux

SSH (Secure Shell) is used to handle network services securely over an unsecured network. Some examples include: remote command-line, login, and remote command execution. In this article you will learn how to enable SSH access for a root user on the Ubuntu 20.04 Server/Desktop.

Enable Root Login via SSH in Ubuntu 20.04​

By default, SSH on Ubuntu comes configured in a way that disables the root users log in. This was originally enabled as a security precaution which means that you cannot directly log in as the root user over SSH. However, you can usually get around the need for root ssh login by using the sudo command.

Set Root password​

After login to Ubuntu 20.04, Now type following command for reset/set root password.
Code:
sudo passwd root
After type the command, maybe Ubuntu 20.04 check your password username. first, you put your username’s password and when you see a prompt for a new password, type a new password for root and confirm that.
you succeed to change the root password, now you need to change some configuration on /etc/ssh/ssh_config for the permit root login.

Configure SSH config to permit root login​

Open the /etc/ssh/sshd_config file with administrative privileges and change the following line:
Code:
nano /etc/ssh/sshd_config
Code:
FROM:
#PermitRootLogin prohibit-password
TO:
PermitRootLogin yes
After edit the SSH config file, press Ctrl+ x and press Enter button twice for save and exit.
The quick way to do this job could be just to simply use the sed command as shown below:
Code:
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
Restart SSH service for loading new configuration on SSH_config file.
Code:
sudo systemctl restart ssh
Now you can check SSH via Root user.
 
Top