6

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.

Ghanima
  • 15,855
  • 15
  • 61
  • 119

2 Answers2

3

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

mystery
  • 518
  • 2
  • 11
  • 1
    This only prevents logins via SSH not directly from the keyboard. – Steve Robillard 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. – AndrolGenhald Feb 20 '18 at 04:08
2

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

techraf
  • 4,319
  • 10
  • 31
  • 42
  • passwd -l is short for passwd --lock :D – mystery May 01 '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. – Phill Healey Apr 13 '20 at 14:21