I changed my password but I forgot it.
How can I recover it?
I changed my password but I forgot it.
How can I recover it?
Unfortunately, as pointed out by goldilocks, you cannot get the text of your old password. You can, however, reset your password by booting directly into the root shell (assuming you have physical access to the RPi). I've had to do this a couple times because of my own poor password keeping practices....
Step 1: Insert RPi SD Card Into Another Computer
Step 2: Backup cmdline.txt onto your computer.
Step 3: Edit cmdline.txt
init=/bin/sh
to the end of that line. This will make Raspbian skip the normal boot up procedure and dump you into the root shell.Step 4: Password Reset!
Boot up the pi and you should be greeted by the root prompt. Simply enter:
passwd pi
If your username isn't pi (unlikely), then simply replace 'pi' with your username. This will then ask you to enter a new password
Step 5: Cleanup
init=/bin/sh
from the end of cmdline.txt on the SD card.You're done! Hopefully that helped.
Source: Personal experience and https://www.raspberrypi.org/forums/viewtopic.php?t=20397
You cannot because the password is not stored anywhere. Secure passwords systems use a one way hash algorithm. Such an algorithm will always produce the same output given the same input, but it is not reversible -- there is no way to turn that output back into the input. This is what makes such password systems secure. It means, for example, if someone steals the database of everyone's password hashes, they are useless. Occasionally in the past a few surprising large tech companies have not bothered with this technique and caused havoc when the databases are stolen and users turn out to be using the same password in multiple places. (Since this is really "computer science 101" level stuff, those companies should probably be held responsible for damages via criminal negligence but I don't think that has ever happened -- presumably this is somewhere long-winded "terms of use" waivers come into play)
However, you can easily disable the password so that you can login without one. There is an example explanation here of how to do this. You either need root access to the system, in which case you can do it on a running system, or else you'll have to take the card out and edit /etc/shadow
somewhere else.
Afterward, when you try to log in as that user and are prompted for a password, just hit enter. You can then replace your password later by running passwd
.