How to Enable Direct login for root

If you’re just playing around on a Raspberry Pi and you don’t feel like constantly sudoing to root, enable root to login directly! Sure this is not best practice and it promotes bad sysadmin behaviours, but it’s a real time saver when you’re just playing in the Raspberry PI sandbox and you don’t care about security or safety. It’s like joyriding without your helmet on.

Here’s the trick to allowing root to login to a Raspberry. By default, ssh is turned off, so you’ll need to enable that. Then, you can make your Raspberry less secure by allowing root in without first sshing as a regular user.

Edit the ssh configuration

vi /etc/ssh/sshd_config

grep for the following:

#PermitRootLogin prohibit-password

and change it to

PermitRootLogin yes

Don’t forget to remove the octothorpe (#) to uncomment the line! Save the file and restart sshd:

systemctml restart sshd

Yes, this will break your ssh connection, but it will resume once sshd restarts. Now, log out and log back in as root. You did, at least, set / change root’s password, didn’t you?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.