Skip to main content

Enable SSH for root user on Ubuntu

To enable root Login, first assign the password for root user.:

#sudo passwd root

#enter new password for root user here.

Directly copy and paste this below lines in command prompt, to set ssh to allow root logins.:

sed -i 's/Authentication:/#Authentication:/g' /etc/ssh/sshd\_config

sed -i 's/LoginGraceTime/#LoginGraceTime/g' /etc/ssh/sshd\_config

sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd\_config

sed -i 's/PermitRootLogin without-password/#PermitRootLogin without-password/g' /etc/ssh/sshd\_config

sed -i 's/StrictModes yes/#StrictModes yes' /etc/ssh/sshd\_config

service ssh restart

Or you can also configure it by manually by editing configuration file as mentioned below.:

#vim /etc/ssh/sshd\_config

_images/59.png

Comment lines as mentioned above.

Save and exit the file.

Now restart ssh service

#service ssh restart

Check from the client machine.