I have made several personal configuration changes to a Raspbian Wheezy install (more secure ssh, personal configurations, etc). It's been a couple weeks since I last touched it, and I completely forgot the password to login. What should I do?
5 Answers
Right off the bat, let me say that there is not a way to recover a password (without some actual cracking/hacking which I don't know how to do). Resetting your password is your best bet.
So the first step will be to determine if you have any way to log in to the Raspbery Pi.
If you're able to log in with a user that has 'sudo' rights (this includes SSH... perhaps you have keys set up properly but forgot the actual user password, which I ran in to), simply typing:
sudo passwd
should prompt you to create a new password (without having to enter your current password).
Another option would be to run the starting config and change the password that way.
sudo raspi-config
If you're completely locked out, you can try the technique mentioned here, though I didn't have any success with the strategy. It just kept me from finishing booting up the RPi.
I haven't found any good techniques to enable root access period (putting the conversation of why you'd even want to do that aside :) ), let alone if you can't log in. Somebody can correct me if I'm wrong.
Hopefully this will save you from blowing away an image with a fresh one. If this saves one person, figure it's worth the time to post :)
Mount the SD card, go into the file system, and edit /etc/passwd. Find the line starting with "pi" that begins like this:
pi:x:1000:1000...
Get rid of the x; leave the colons on either side. This will eliminate the need for a password.
You probably then want to create a new password by using the passwd command after you log in.
- 60,325
- 17
- 117
- 234
- 349
- 2
- 2
If you have physical access to the pi, look at these instructions. Essentially, mount the SD card using a different machine and edit cmdline.txt to include (at the end) init=/bin/sh. Then, run the following commands:
mount -o remount,rw /
passwd pi
(enter a new password)
sync
exec /sbin/init
- 321
- 2
- 6
As Jamie Cox commented in one answer and what actually worked for my problem, you might want to change the password for the pi user, so type
sudo passwd pi
otherwise you are just changing the password for root.
- 91
- 1
- 1
I assume you have physical access to your SD.
Step 1:
Create new password: openssl passwd -6 -salt mysalt my-new-password, where both "my-*" strings are something you should make unique, obviously.
You will receive something like: $6$salt$phlWRlSMVXZ1JJxGL/j5ANI.m8sbGpNT5pQE8iyx2TxYPKIZZhPM.eMN0axmoRHY3CrZU2KeyhTOcjBkKeD.N/
Step 2:
option 1: edit
/etc/shadowon your Pi's SD's root partition and replace the encrypted password with newly generated oroption 2a: edit
/etc/rc.localand say "echo 'pi:<plaintext-password>' | chpasswd" or (because it's not secure in case you forget to remove this command afterwards)option 2b: in the same file say "
echo 'pi:<generated-password>' | chpasswd -e", which is safer, because the password is not readable
Note: option 2 will cause the password reset after every reboot, so when you have your password reset, you should remove the command from /etc/rc.local
- 219
- 2
- 7