Occasionally I forget the Raspberry Pi password on my projects. It’s a pain but this guide provides a technique to reset the password and gain access to the system and get it back up and running. You need physical access to the SD card, a separate PC and the ability to connect your Pi to a monitor and keyboard. I used a Windows PC but this should work fine on a Mac or Linux machine.
SSH using Linux or Mac OS. The default password on Raspbian is raspberry. For security reasons it is highly recommended to change the default password on the. Oct 11, 2016 - In Raspberry Pi from version Jessie onwards the 'root' login for SSH sessions (via Putty Login) has been disabled by default. It can be enabled.
Step 1 – Pi Password Recovery Requirements
To use this technique you must :
- Have physical access to the Pi and its SD card
- Access to a keyboard and monitor
- Suitable adapters if you are using a Pi Zero
- Have a PC/laptop with a microSD card reader
Step 2 – Grab The SD Card
Power down the Pi and remove the SD card. Insert it into your PC.
Step 3 – Edit cmdline.txt
The boot partition should be visible and contain a file named “cmdline.txt”. Edit this file in a text editor and add the following to the end of the existing text :
![Change admin password Change admin password](https://www.maketecheasier.com/assets/uploads/2017/09/how-to-secure-raspberry-pi-raspbian-os-header.jpg)
If the original content was :
it should now look like :
Make sure it is all one line! Save the text file and eject the SD card from the PC.
Step 4 – Reset the Pi Password
Insert the card into the Pi with a monitor and keyboard connected. Power up the Pi. There may be a delay but you should be presented with a cursor.
At the prompt type the following command :
If this results in an error message such as :
simply try the mount command again :
Finally you can now attempt to change the password :
You will then be prompted for a new password. Enter it carefully and press the [Return] key. It will now ask you to retype the password.
The password has been changed.
Now type the following commands :
The Pi will continue to boot and return you to the normal command line prompt.
Shutdown the Pi and power it off.
Step 5 – Edit cmdline.txt
Remove the SD card from the Pi and using the PC edit the “cmdline.txt” file again and remove the “init=/bin/sh” text you added in Step 2.
Safely eject the SD card from the PC and re-insert into the Pi.
Power up the Pi and your new password should now be active.
Now, don’t forget that password again!