By default, Ubuntu discourages remote access as the root user via SSH for security reasons. The root account is often targeted by attackers due to its unrestricted privileges. However, in some scenarios, it may be necessary to enable SSH login as the root user. This blog will guide you through the steps required to allow root user access using SSH in Ubuntu Linux.
To enable root user access via SSH, you should already have a remote connection established with your Ubuntu server. This can be achieved using an SSH client such as OpenSSH or PuTTY.
Enable root user access
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
Update the root user’s password (optional)
If you haven’t already set a password for the root user, you can do so by executing the following command:
sudo passwd root
To apply the changes, restart the SSH service by executing the following command:
sudo systemctl restart sshd
Enabling root user access via SSH in Ubuntu Linux can be done by modifying the SSH server’s configuration file and restarting the service. However, it is crucial to note that allowing root access increases security risks. It is advisable to use the root user selectively and prefer secure alternatives, such as using sudo to execute privileged commands under an individual user account. Keep in mind that security should always be a top priority when managing Linux systems.