Page 1 of 1

Password

Posted: Tue Jan 19, 2016 11:35 pm
by jwwphoto
I changed the default username and password for the Rasbian OS Install on my PI. Is there a way to reset. I am guessing re-writing a new image to card would do it but I would lose my customization I have made to my Raspberry Pi.

I just put is away for about 6 months and can remember what I set it to.


Jeff W Waldrop

Re: Password

Posted: Wed Jan 20, 2016 12:30 am
by W. H. Heydt
Yes....there is a way, but you need either added software to enable a Windows system to read and write an ext4 file system, or another Linux system (which could be just a "Live CD" running a conventional PC). The following assumes you are using another Linux system (or using your Pi with a different SD card and able to connect the old card at the same time):

You need to gain access to the ext4 partition on the SD card.
Locate the file /etc/passwd. Edit that file.
Find the line that starts with the ID you need to get back into (e.g. the one that starts with "pi").
Remove the 'x' after the first colon.
The line will then start with "pi::".
Save the file.
Do "sync; sync" to flush the buffers.
Unmount the SD card.
Remove the SD card.
Use the SD card to boot the Pi.
The login ID now has no password.
Set a new password.
Done.

Re: Password

Posted: Wed Jan 20, 2016 7:44 pm
by Navyscourge
No - don't use Windows to mess with that file.

Use the single user mode for Linux by adding "init=/bin/sh" to the text in cmdline.txt in the small boot partition. You can use any other computer, even a Windows one, as it is on a FAT partition, and is a simple text file.

See here for a discussion (somewhat prolonged) about the single user mode - viewtopic.php?p=109612

Re: Password

Posted: Wed Jan 20, 2016 8:39 pm
by flubbard
By saying that you changed the default user and password, do you mean that you created a new user...changed the root user password, or changed the password for the pi user?

If you created a new user or changed the root (but didn't change the pi user itself), you could still log on to the pi user, and then

Code: Select all

sudo passwd [username]
to the change the password of the user you want to change.

- Barry