Linux

Little hacks I found useful and may need to refer to again later, cos it’s all so easy to forget.

Raspberry Pi Change Forgotten Password(s)

On the boot partition of the SD Card, the hashes of the passwords are stored in /etc/shadow, usually towards the end of the file, e.g.

fred:$6$VHuVp9oAbI./.Rc7$FSkBM8Zd3AJoC3w/Mm2hsvuIdufd1rf.Vv2bA3e0kMGACZptC8A5Xt>
nx:*:18853:0:99999:7:::

All we need is the hash itself, which is the string in between the first 2 colons, in this case, $6$VHuVp9oAbI./.Rc7$FSkBM8Zd3AJoC3w/Mm2hsvuIdufd1rf.Vv2bA3e0kMGACZptC8A5Xt> nx –

Get the hash from the same location in another system that you know the password for and then copy it and paste it over the existing one, then save the file, and replace the SD card in the pi. Bot up. Your known password now is active in the Pi.