i forgot the password for my raspberry pi, but it is still stored in the default-settings of the raspberry pi imager. Is there any way to get the password back to plain text. my problem is i dont have a screen + mouse + keyboard avaiable for weeks, and really want to keep the config of my pi. any ideas? can i just copy the stuff from the sd-card except the password-file?
1 Answer
You can fix your Rpi without console. You need to put Rpi's sd card into your PC.
First add to cmdline.txt:
systemd.run=/boot/runonce.sh systemd.unit=kernel-command-line.target
Then create runonce.sh script to set password to what you need:
#!/bin/bash
set +e
echo 'username:password' | chpasswd
rm -f /boot/runonce.sh
sed -i 's| systemd.run.*||g' /boot/cmdline.txt
exit 0
Boot Rpi.
-
I just did that on OctoPi and it didn't work. Any way to see why?– MołotCommented Nov 29, 2023 at 11:37
-
I won't be able to tell. I am unfamiliar with OctoPi but if it uses systemd and FAT partition is mounted on /boot it should work. Commented Dec 5, 2023 at 7:08