Ubuntu Linux

How to permit SSH root Login in Ubuntu 18.04

How to permit SSH root Login in Ubuntu 18.04

SSH root login is disabled by default in Ubuntu 18.04.  SSH server for Ubuntu provides by the openssh-server package and root login is controlled by the PermitRootLogin directive in the OpenSSH server configuration (sshd_config file):

You can check the current status by running the following command:

grep -i "rootlogin" /etc/ssh/sshd_config

Root login is disabled, if the PermitRootLogin directive is commented out (# in front) or its value is not set to yes.

root login is controlled by the PermitRootLogin directive in the OpenSSH server configuration

If you want to enable ssh root login, do the following steps with root privileges:

  1. Open the /etc/ssh/sshd_config:
    vim /etc/ssh/sshd_config
  2. Uncomment the line PermitRootLogin and set the value to yes:
    PermitRootLogin yes
  3. To make the new setting take effect, restart the ssh server:
    systemctl restart sshd.service

Now that we have enabled ssh root login, you can try ssh using the root user from a remote computer:

ssh [email protected]

Note that Ubuntu root account does not have a password by default. So if you want to log in to root ssh account, first you muse have set a password for the root user.

Allowing the root user to login over SSH is a not a good idea. we don’t need to login as root to get root privileges. You can ssh to your Ubuntu server using a user who has sudo privileges, then switch to the root user account using sudo -i command.

Next: Change Ubuntu SSH Port