I was trying to use sudo to change the default account name, but it didn't work. So, I added a password to the root account and logged in as root. By default, you can't login to root through the login screen, adding a password to it allowed this.

It worked, but I have found another problem; I can't figure out how to remove the password again. Several guides online say you can do it, but don't say how.

  • I'm sure this question or a variant of it has been asked here before...
    – Darth Vader
    Apr 29 '17 at 12:32

Disable remote login

Run sudo nano /etc/ssh/sshd_config

and set PermitRootLogin yes to 'no'.

Reboot or restart the ssh service with /etc/init.d/ssh restart

Disable root completely

To completely disable root-access, either lock it via passwd --lock root or remove the password by executing passwd -d root

  • 1
    This only prevents logins via SSH not directly from the keyboard. Apr 29 '17 at 19:37
  • Don't know about older versions but I just found out that Raspbian 9 has pam_unix.so nullok_secure by default, so passwd -d [user] will allow login without a password. passwd -l [user] must be used instead. Feb 20 '18 at 4:08

I just found out that sudo passwd -l root does exactly what I wanted.

  • passwd -l is short for passwd --lock :D
    – mystery
    May 1 '17 at 13:36
  • I used your command to disable root login into the GUI, but I still get prompted for a login, only now root does not work any more and the standard user "pi" is also not logging in - albeit not stating an error, simply showing a login promt again.
    – bomben
    Jul 11 '18 at 10:57
  • 1
    Did you actually use passwd -l with no username/account ? REMEMBER: never use code from the internet without understanding what it does. Apr 13 '20 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.