[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Passwords



On Tue, 17 Jan 2023, Stanislav Vlasov wrote:

??, 17 ???. 2023 ?. ? 11:01, David <david.g_jones@ntlworld.com>:

I have forgotten my password to a Debian PC using an SD stick as it's
main drive.

Looking on the internet it says the passwords are stored in /etc/passwd
and /etc/shadow

In /etc/shadow only password's hashes, some data, one-way calculated
from password string.

The password string in /etc/shadow looks as if it's encoded, how can I
read this string?

You can't.
But you can set new password, if you boot from live-usb/live-cd, mount
your system to dir and run `chroot dir && passwd $user`


One other thing you can do if you don't have a quick and easy way to
boot is to manually replace the hash in /etc/shadow with one that you do
know the password for. (This might be the case, for example, where the
USB stick is for booting ARM but all your other machines are x86, mount,
change password, umount is much quicker than trying to work out how to
live boot a headless arm system...)

This is something I did in ancient times when most systems still used
crypt and the system I was having problems with was the only one (so
far) that had been converted to use SHA? hashes. I replaced root's hash,
which I'd forgotten with that of my user account, which I did know.

And if you don't have any hashes that you know the password for then ask
here, someone can generate one for you - or see this thread:

https://unix.stackexchange.com/questions/81240/manually-generate-password-for-etc-shadow

Obviously manually editing these files isn't something to be done
without care. I always have backups so worst case is "restore from
backup" and not "I've lost everything"



Reply to: