I forgot the password for my Pi. This is the technique I found for resetting the pi user password.
Step 1 – Remove the SD Card
Remove the SD card from the Pi and insert it into your PC.
Step 2 – Edit cmdline.txt
In the boot partition there is a file named “cmdline.txt”. Edit this file in a text editor and add the following to the end of the existing text:
init=/bin/sh
Make sure it is all one line!
Save the text file and eject the SD card from the PC.
Step 3 – 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 :
mount -o remount, rw /
You may see an error message. Just enter the above command again.
/bin/sh: 0: can’t access tty; job control turned off [ 21.366191] random: crng init done
Enter the command to change the pi password
passwd pi
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 :
sync
exec /sbin/init
The Pi will continue to boot and return you to the normal command line prompt.
Log in to the pi with the new credentials
Shutdown the Pi and power it off.
sudo halt
Step 4 – 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.
Remove SD card from the PC and re-insert into the Pi.
Power up the Pi and login with your new password.