0

I have a raspberry pi 4 that I haven't used in a little bit, and I've forgotten the password. I know it's running raspbian lite, no idea which version. I'd really hate to wipe it, there were many hours of setup that went into it.

I've read some posts about starting by editing the /etc/shadow file, but I can't seem to find it when I plug my micro SD card into my mac, even when revealing hidden files.

I've also tried adding init=/bin/sh to the end of the cmdline.txt file, but to no avail. When I do that, in fact, I can't even ssh into the pi, seems like it's not quite booting right.

Any thoughts on this pickle?

1
1

You need to attach a screen and keyboard and then do the init=/bin/sh. It will sit there waiting for you to enter a command.

1

You can reset password on the Pi by rebooting to a root shell. (This requires a keyboard & screen).

  1. Append init=/bin/sh at the end of cmdline.txt and reboot.
  2. After booting you will be at the prompt in a root shell.
  3. Your root file system is mounted as readonly now, so remount it as read/write mount -n -o remount,rw /

macOS can not (easily) access ext4 partitions so you can not edit /etc/shadow, although this is possible on any Linux OS - even the Pi.

If you don't want to lose your files I suggest you do a fresh install into a new SD Card.

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.