Articles Hierarchy

Articles Home » RPI » RPI password reset

RPI password reset

RPI password reset possible?

to change your password ( of user pi ) type
and give current password and type 2 times new password.

as user pi has sudo priv
you can also use
sudo su
passwd pi

OR only
sudo passwd pi
and type 2 times new password,
because as admin you are not asked for your password to change other users password.

if you ( have no HDMI / TV ) are headless, you can have yourself logged out.
so use the SD card in card reader...

i see a note at some web site and i started testing,
but first make a new setup anyway
and as part of the procedure change the password of user pi.
But first i make a note of the user pi password setting:
sudo cat /etc/shadow
so that
is the (a) password raspberry hash.
with sudo nano /etc/shadow you can edit that line and change password back to raspberry,

but that's the point: if you locked yourself out! how to do that?
so i just put the SD back in the card reader, put that in the USB of a RPI ( with a running system ) and search for the card reader mount:
cd /media/pi/xxxxxxxxxxxxxxx but not boot xxx/etc/
sudo nano shadow

as i work headless, ! that is so easy only if the boot option is "pi login to desktop"
what includes a auto mount ( of USB drives... ) !
and here the tested SED line:
cd /etc/
sudo sed shadow -i -e "/^pi:/s|.*|pi:\$6\$pLTmrmp1\$r5M8L6MKyu/6wyva0h4DSdZzdUnD0FmQF8PWLtKLSAGQ4EE95VsytHkbnyP3aDhh8EMq/Td2APtyyevKp8XSs.:17228:0:99999:7:::|"
note: i needed s||| for separation and \$ for each $ in HASH

want read about that shadow file thing? here

now check for a other way from forum
sudo nano /media/pi/boot/cmdline.txt
add " init=/bin/bash"
see here or check systemd
i try from TV but could not read all terminal window, several linux commands did not work,
go back to card reader and change back.
next day try again.
i change the /boot/cmdline.txt from remote and sudo reboot ( while TV ON waits for HDMI )
now screen readable
on passwd can type new password / retype password ( ok, not ask for old password )
but get error and password unchanged
and get error failed to read mtab
but anyhow try
mount -o remount,rw /

and get password updated successfully
good, i even tested nano... works also but can not reach /boot/
( there is a /boot/ but empty, the real /boot/ not mounted )
so again, go back card reader to repair cmdline.txt.