SSH on Ubuntu comes configured by default in a way that disables the root users log in. This was originally setted as a security precaution which means that you cannot directly log in as the root user over SSH. In some cases, though it’s just more convenient to get directly logged in as root.
Enable root login over SSH
- Login to your server as root.
- As the root user, edit the sshd_config file found in /etc/ssh/sshd_config:
- Add the following line to the file, you can add it anywhere but it’s good practice to find the block about authentication and add it there.
- Save and exit the file.
- Restart the SSH server:
systemctl restart sshd
service sshd restart
With the new line added and the SSH server restarted, you can now connect via the root user.
This process works on almost all versions of Linux-based servers on which the sshd service is installed. If you use a server with cPanel or WebMin interface, you can check the settings from the control panel interface.