2

I changed my password but I forgot it.

How can I recover it?

1
  • 1
    If you have a clue what it might be you could try guessing. But you may be better off reburning the SD card, and taking this as a lesson learned. You may also want to get a password db like keepass. Commented Jun 27, 2016 at 22:55

2 Answers 2

5

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

  • This is pretty self explanatory....

Step 2: Backup cmdline.txt onto your computer.

  • Just in case you accidentally mess something up, its always good to have a backup!

Step 3: Edit cmdline.txt

  • The file should only have one line, and you need to add 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

  • Now you just have to remove 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

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.