How to reset a forgotten Raspberry Pi password: SD card method

Step-by-step password recovery for Raspberry PLC, GateBerry, and Touchberry Pi
June 18, 2026 by
How to reset a forgotten Raspberry Pi password: SD card method
Joan F. Aubets - Industrial Shields

The default Raspberry Pi OS password is set during initial configuration. If you skipped that step, lost your notes, or inherited a device, you can still recover access without reinstalling the OS. This guide covers the SD card method, which works on any Raspberry Pi running Raspberry Pi OS — including Industrial Shields Raspberry PLC, GateBerry, and Touchberry Pi.

Requirements

  • Raspberry Pi device — Raspberry Pi board, Raspberry PLC, GateBerry, or Touchberry Pi
  • A second computer (Windows, macOS, or Linux) with a microSD card reader
  • Monitor and keyboard connected to the Raspberry Pi device

Step-by-step tutorial

1. Power off the device completely. Remove the microSD card and insert it into the reader on your secondary computer.

2. On the boot partition (FAT32 — visible on Windows and macOS without extra tools), open cmdline.txt in a plain text editor. Add init=/bin/sh at the very end of the single line — do not press Enter or create a new line:

console=tty1 root=PARTUUID=4daa237a-02 rootfstype=ext4 fsck.repair=yes rootwait init=/bin/sh

3. Save the file, eject the card safely, reinsert it into the device, and power on. The device boots directly to a root shell instead of the normal login prompt.

4. Remount the filesystem as read-write:

mount -o remount,rw /

If you get a job control error on the first attempt, run the command again — it succeeds on the second try.

5. Change the password:

passwd pi

Replace pi with your actual username if different. Enter and confirm the new password when prompted.

6. Sync and power off:

sync
halt

7. Remove the microSD card, open cmdline.txt on your computer, and delete init=/bin/sh from the line. Save, reinsert, and power on — the device boots normally with the new password.

Password security recommendations

While you have access to the microSD card, it is worth reviewing the credential policy for any device deployed in the field:

  • Set a password of at least 12 characters mixing letters, numbers, and symbols
  • Never leave the default raspberry password on any deployed device
  • Disable password authentication over SSH and switch to key-based authentication — edit /etc/ssh/sshd_config and set PasswordAuthentication no
  • Install fail2ban to block repeated failed login attempts: sudo apt install fail2ban
  • Keep a secure offline record of credentials per device — not in a shared spreadsheet

Industrial Shields Raspberry Pi-based products

Raspberry PLC, GateBerry, and Touchberry Pi from Industrial Shields all run standard Raspberry Pi OS on the same partition structure as a bare Raspberry Pi board. The password recovery method above works identically on all of them. The only practical difference is physical access to the microSD card slot, which varies by model — check the hardware datasheet for your specific product for the slot location.

​Search in our Blog

How to reset a forgotten Raspberry Pi password: SD card method
Joan F. Aubets - Industrial Shields June 18, 2026
Share this post
Tags

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

PLC Comparison