Skip to content

Ubuntu enable SSH for root user

Danger

This is a very bad idea for servers on open internet. Only recommended for servers on local network that are behind firewall and SSH is not accessible from internet. To be used for testing only.

Install openssh-server

First install openssh server if not installed along with nano editor

1
2
3
sudo nano apt update
sudo nano apt upgrade
sudo apt install openssh-server nano

Set root password

Change or set root user password

1
sudo passwd

Enable root user login

Edit the ssh config file:

1
sudo nano /etc/ssh/sshd_config

Find the line that says:

1
#PermitRootLogin prohibit-password

And change it to:

1
PermitRootLogin yes

Save and exit using Ctrl+x followed by Y and then press Enter

Finally enable SSH during boot and restart it:

1
2
systemctl enable ssh
systemctl restart ssh

You can check the IP address of the server by running the command:

1
ip addr