Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
1 answers
138 views
/etc/shadow file and password storing algorithm in Linux
I don't know what's algorithm of storing password in `/etc/shadow` in Linux. I tested via the following script via python: import hashlib message = b"123" md5_hash = hashlib.md5(message).hexdigest() sha1_hash = hashlib.sha1(message).hexdigest() sha256_hash = hashlib.sha256(message).hexdigest() sha38...
I don't know what's algorithm of storing password in /etc/shadow in Linux.
I tested via the following script via python: import hashlib message = b"123" md5_hash = hashlib.md5(message).hexdigest() sha1_hash = hashlib.sha1(message).hexdigest() sha256_hash = hashlib.sha256(message).hexdigest() sha384_hash = hashlib.sha384(message).hexdigest() sha512_hash = hashlib.sha512(message).hexdigest() print(f"MD5: {md5_hash}") print(f"SHA-1: {sha1_hash}") print(f"SHA-256: {sha256_hash}") print(f"SHA-384: {sha384_hash}") print(f"SHA-512: {sha512_hash}") But I did't see my password.My password is 123.
1. Does shadow store as HASH? if yes I should discard getting password.
2. If password doesn't store as hash, How can I get it?
PersianGulf (11308 rep)
Feb 22, 2025, 06:16 AM • Last activity: Feb 22, 2025, 04:19 PM
67 votes
4 answers
114136 views
Difference between ! vs !! vs * in /etc/shadow
The second field in the Linux `/etc/shadow` file represents a password. However, what we have seen is that: 1. Some of the password fields may have a single exclamation :!:..... 2. Some of the password fields may have a double exclamation :!!:..... 3. Some of the password fields may have an asterisk...
The second field in the Linux /etc/shadow file represents a password. However, what we have seen is that: 1. Some of the password fields may have a single exclamation :!:..... 2. Some of the password fields may have a double exclamation :!!:..... 3. Some of the password fields may have an asterisk sign :*:..... By some research on internet and through this thread , I can understand that * means password never established, ! means locked. Can someone explain what does double exclamation (!!) mean? and how is it different from (!)?
JavaTec (847 rep)
Dec 28, 2015, 10:55 PM • Last activity: Dec 19, 2024, 10:29 AM
2 votes
1 answers
748 views
Why does the salt value in /etc/shadow say "rounds=..."?
I have an embedded Linux device with a fairly modern Linux kernel. However, a strange thing happened with the last update: when a password is modified with `passwd` for any user, the salt value in `/etc/shadow` is replaced with `rounds=65536`, so an entry will look like `root:$6$rounds=65536$6mA...`...
I have an embedded Linux device with a fairly modern Linux kernel. However, a strange thing happened with the last update: when a password is modified with passwd for any user, the salt value in /etc/shadow is replaced with rounds=65536, so an entry will look like root:$6$rounds=65536$6mA.... I suspect PAM is doing this. Does anyone have any idea what issue with PAM could cause such behaviour?
Robindev (23 rep)
Oct 14, 2024, 03:26 PM • Last activity: Oct 15, 2024, 09:06 AM
36 votes
2 answers
124352 views
/etc/shadow : how to generate $6$ 's encrypted password?
In `/etc/shadow` file there are encrypted password. Encrypted password is no longer `crypt(3)` or md5 "type 1" format. ([according to this previous answer][1]) Now I have a $6$somesalt$someveryverylongencryptedpasswd as entry. I can no longer use openssl passwd -1 -salt salt hello-world $1$salt$pJUW...
In /etc/shadow file there are encrypted password. Encrypted password is no longer crypt(3) or md5 "type 1" format. (according to this previous answer ) Now I have a $6$somesalt$someveryverylongencryptedpasswd as entry. I can no longer use openssl passwd -1 -salt salt hello-world $1$salt$pJUW3ztI6C1N/anHwD6MB0 to generate encrypted passwd. Any equivalent like (non existing) .. ? openssl passwd -6 -salt salt hello-world
Archemar (32267 rep)
Sep 30, 2014, 11:25 AM • Last activity: Jul 10, 2024, 02:21 PM
0 votes
1 answers
59 views
Debian passwd package sources - Unable to find patch that modifies passwd utility options
I noticed `passwd` utility doesn't support the `-s/--stdin` option on Debian which allows to read password from standard input. With this option you can do something like `echo mypassword | passwd -s mylogin` to set password for specific login from script. I just wanted to try it but noticed it is n...
I noticed passwd utility doesn't support the -s/--stdin option on Debian which allows to read password from standard input. With this option you can do something like echo mypassword | passwd -s mylogin to set password for specific login from script. I just wanted to try it but noticed it is not possible on Ubuntu nor Debian which is base for Ubuntu. It will print error that option is not recognized. So i went to Debian sources for **passwd** package (it's here https://salsa.debian.org/debian/shadow/-/tree/master/debian?ref_type=heads) and tried to find the patch that removes the option because in the original source code for passwd utility the option is still there (https://salsa.debian.org/debian/shadow/-/blob/master/src/passwd.c?ref_type=heads#L166) . **I can't find the patch in the repository, it looks like it's not there. Can anybody help me to find it?** I don't know the workflow that is used to patch the original source code but i expected the patch to be there because there is folder with patches (https://salsa.debian.org/debian/shadow/-/tree/master/debian/patches/debian?ref_type=heads) . Thank you.
designerrr (111 rep)
Jul 7, 2024, 06:06 PM • Last activity: Jul 7, 2024, 08:03 PM
6 votes
3 answers
20746 views
What is the difference between /etc/shadow and /etc/passwd?
It seems to me that `/etc/shadow` and `/etc/passwd` contain the same data. Why are there two files? Are they different?
It seems to me that /etc/shadow and /etc/passwd contain the same data. Why are there two files? Are they different?
Rahul Kamboj (203 rep)
Aug 7, 2018, 09:32 AM • Last activity: May 28, 2024, 07:25 AM
4 votes
2 answers
1774 views
How can the shadows around windows be removed from Mate with Lightdm?
There is a shadow around each window in Mate. If it matters I run Lightdm. How can the shadows be completely disabled for all windows regardless of the application?
There is a shadow around each window in Mate. If it matters I run Lightdm. How can the shadows be completely disabled for all windows regardless of the application?
user364407 (41 rep)
Jul 28, 2019, 04:43 PM • Last activity: Jan 25, 2024, 06:51 PM
0 votes
1 answers
45 views
How to syncronize credentials in a small laboratory? (very slim alternative to ldap)
We run a small lab with 20 Linux systems (RaspberryPI, NAS, Desktop PCs) for research with 4 scientists who all need sudo permissions. We trust all 4 users as they have sudo permission and physical access any way. The laboratory network is a local network and not accessible from the internet. Now we...
We run a small lab with 20 Linux systems (RaspberryPI, NAS, Desktop PCs) for research with 4 scientists who all need sudo permissions. We trust all 4 users as they have sudo permission and physical access any way. The laboratory network is a local network and not accessible from the internet. Now we would like to synchronize the credentials. If one user changes the password, it should not be changed manually on the other 19 systems. I would like to avoid complex solutions like LDAP. The first idea which came into my mind was to maintain the credentials on the NAS as single source and copy them via scp to the clients in a systemd module. But I guess I am reinventing the wheel and there are ready to use packages/solutions and I just tried the wrong search terms. Which package or solution is commonly used for such a scenario?
Jonas Stein (4298 rep)
Dec 23, 2023, 12:53 PM • Last activity: Dec 24, 2023, 09:04 PM
0 votes
1 answers
127 views
I've forgotten my password but am logged in--what tools can I use to assist in recovery and limit damages?
I have an encrypted hard drive. The hard drive, root user, and primary user all share the same password. I have successfully logged in but seem to have forgotten the password. I'm looking to limit the damage of this forgotten password and attempt to recover it. The steps I am taking so far are the f...
I have an encrypted hard drive. The hard drive, root user, and primary user all share the same password. I have successfully logged in but seem to have forgotten the password. I'm looking to limit the damage of this forgotten password and attempt to recover it. The steps I am taking so far are the following: * Write down the password as best I can remember it. * Email a copy of /etc/passwd to myself so I can attempt to run a brute force attack on it with the characters from the prior step. * Backup unsaved data and files as best I can. Does anyone have any suggestions on a tool to use to brute force /etc/passwd? Update: It looks like the hashed passwords are now in /etc/shadow so if I want to run this brute force I need to do it now while I have a login prompt... I have no root shell and cannot sudo since it's the same password.
mpr (1194 rep)
Nov 24, 2023, 03:35 AM • Last activity: Nov 24, 2023, 04:41 AM
184 votes
10 answers
438769 views
Manually generate password for /etc/shadow
I need to manually edit `/etc/shadow` to change the root password inside of a virtual machine image. Is there a command-line tool that takes a password and generates an `/etc/shadow` compatible password hash on standard out?
I need to manually edit /etc/shadow to change the root password inside of a virtual machine image. Is there a command-line tool that takes a password and generates an /etc/shadow compatible password hash on standard out?
Lorin Hochstein (8605 rep)
Jun 30, 2013, 05:41 PM • Last activity: Nov 19, 2023, 04:00 AM
0 votes
0 answers
50 views
How to calculate the password hash in /etc/shadow
I have the following line in my `/etc/shadow` file (`SALT` and `HASHED_PASSWORD` are not real values for obvious reason). And I understand `$6` means SHA512 is used. ``` testuser:$6$SALT$HASHED_PASSWORD:19591:0:99999:7::: ``` I wonder how do I combine the `SALT` and my real password `PASSWD` as inpu...
I have the following line in my /etc/shadow file (SALT and HASHED_PASSWORD are not real values for obvious reason). And I understand $6 means SHA512 is used.
testuser:$6$SALT$HASHED_PASSWORD:19591:0:99999:7:::
I wonder how do I combine the SALT and my real password PASSWD as input for SHA512 to get the HASHED_PASSWORD value? I tried to run sha512sum command and paste in PASSWD+SALT and SALT+PASSWD (without the + sign). But the result is nothing like the HASHED_PASSWORD stored in the file.
DrizzleX (125 rep)
Aug 22, 2023, 04:09 AM
0 votes
2 answers
664 views
Difference between *LK* in /etc/shadow and /usr/sbin/nologon in /etc/passwd
What is the practical difference between setting `*LK*` in `/etc/shadow` and setting `/usr/sbin/nologon` in `/etc/passwd`? When would we choose one over the other? When would we combine them?
What is the practical difference between setting *LK* in /etc/shadow and setting /usr/sbin/nologon in /etc/passwd? When would we choose one over the other? When would we combine them?
Lyubomir (113 rep)
Jun 5, 2023, 08:44 PM • Last activity: Jun 5, 2023, 11:25 PM
0 votes
1 answers
230 views
Difference between passwd and passwd- file as well as shadow and shadow- file
on my server running UnraidOS I got a bit suspicious. There are both 'passwd' and 'passwd-' files (same goes for shadow(-)). These ones should be only backups as I understood. Running: root@Unraid-server:~# diff /etc/passwd{,-} delivers: 2,8c2,8 bin:!:1:1:bin:/bin:/bin/false > daemon:!:2:2:daemon:/s...
on my server running UnraidOS I got a bit suspicious. There are both 'passwd' and 'passwd-' files (same goes for shadow(-)). These ones should be only backups as I understood. Running: root@Unraid-server:~# diff /etc/passwd{,-} delivers: 2,8c2,8 bin:!:1:1:bin:/bin:/bin/false > daemon:!:2:2:daemon:/sbin:/bin/false > adm:!:3:4:adm:/var/log:/bin/false > ftp:!:14:50::/home/ftp:/bin/false > rpc:!:32:32:RPC portmap user:/:/bin/false > sshd:!:33:33:sshd:/:/bin/false > ntp:!:44:44:User for NTP:/:/bin/false 10,14c10,14 dhcpcd:!:68:68:dhcp PrivSep:/var/lib/dhcpcd:/bin/false > avahi:!:61:214:Avahi Daemon User:/dev/null:/bin/false > avahi-autoipd:!:62:62:Avahi AutoIP Daemon User:/dev/null:/bin/false > messagebus:!:81:81:User for D-BUS:/var/run/dbus:/bin/false > nobody:!:99:100:nobody:/:/bin/false As it seems, only all the 'x' for '!' were changed in the back-uped version. Nothing changed here in terms of the user id, just the 'locked' status was applied. **A) This is correct and not suspicious, right?** For shadow it is a bit different: root@Unraid-server:~# diff /etc/shadow{,-} 2,11c2,11 bin:!:19451:0:99999:7::: > daemon:!:19451:0:99999:7::: > adm:!:19451:0:99999:7::: > ftp:!:19451:0:99999:7::: > rpc:!:19451:0:99999:7::: > sshd:!:19451:0:99999:7::: > avahi:!:19451:0:99999:7::: > avahi-autoipd:!:19451:0:99999:7::: > messagebus:!:19451:0:99999:7::: > nobody:!:19451:0:99999:7::: 15c15 ntp:!:19451:::::: 17c17 dhcpcd:!:19451:::::: **Shouldn't there be the same user-id on shadow as well as shadow-? Why are the user-id's changed between the original file and the backup? -> on my /boot/config file the user-id of original shadow file are equivalent.**
Dakanomo (1 rep)
Apr 23, 2023, 10:05 AM • Last activity: Apr 23, 2023, 12:11 PM
0 votes
1 answers
113 views
Need help with a script that uses passwd and shadow
I would like assistance with something I have to do. I need to verify if all users in passwd are also in shadow, if the primary group exists, if the homedir exists and if it belongs to the correct user/group. If something is wrong, it should output it to a new file, called for example "errors". How...
I would like assistance with something I have to do. I need to verify if all users in passwd are also in shadow, if the primary group exists, if the homedir exists and if it belongs to the correct user/group. If something is wrong, it should output it to a new file, called for example "errors". How can I implement a script that does this?
UserAsker312 (3 rep)
Jan 2, 2021, 05:30 PM • Last activity: Mar 30, 2023, 07:46 PM
21 votes
2 answers
38110 views
Disable password on linux user with command
Based on [`/etc/shadow(5)` documentation][1] on the second (password) field: > ### encrypted password > > If the password field contains some string that is not a valid result > of crypt(3), for instance ! or *, the user will not be able to use a > unix password to log in (but the user may log in th...
Based on /etc/shadow(5) documentation on the second (password) field: > ### encrypted password > > If the password field contains some string that is not a valid result > of crypt(3), for instance ! or *, the user will not be able to use a > unix password to log in (but the user may log in the system by other > means). My question is whether there is a linux command to disable the user password,i.e. set a "*" or a "!" on password field.
trikelef (460 rep)
Dec 23, 2019, 11:14 AM • Last activity: Feb 5, 2023, 09:52 AM
0 votes
0 answers
103 views
Password manager which gets unlocked by logging in into your session other than GNOME Keyring
Windows has a neat feature: it has a built-in password manager/storage which gets unlocked automatically when you log in. Are there any Linux applications which are linked to `pam.d`, so that entering your *valid* password is enough to get their stored passwords unlocked/unecrypted? A bonus feature...
Windows has a neat feature: it has a built-in password manager/storage which gets unlocked automatically when you log in. Are there any Linux applications which are linked to pam.d, so that entering your *valid* password is enough to get their stored passwords unlocked/unecrypted? A bonus feature would be to be able to run something like password=$(password_manager --item certain_item --show). AFAIK there's gnome-keyring but what if I don't use Gnome? There's a feature request for keepassxc but it's not implemented yet: https://github.com/keepassxreboot/keepassxc/discussions/5879
Artem S. Tashkinov (32730 rep)
Nov 28, 2022, 06:59 AM • Last activity: Nov 28, 2022, 07:53 AM
9 votes
1 answers
6347 views
What does j9T mean in yescrypt (from /etc/shadow)?
Consider this Shadow string ``` $y$j9T$PaFEMV0mbpeadmHDv0Lp31$G/LliR3MqgdjEBcFC1E.s/3vlRofsZ0Wn5JyZHXAol5 ``` There are 4 parts - id : y (yescrypt) - param : j9T - salt : PaFEMV0mbpeadmHDv0Lp31 - hash : G/LliR3MqgdjEBcFC1E.s/3vlRofsZ0Wn5JyZHXAol5 **Q:** 1. What does `j9T` in param field mean? 2. Are...
Consider this Shadow string
$y$j9T$PaFEMV0mbpeadmHDv0Lp31$G/LliR3MqgdjEBcFC1E.s/3vlRofsZ0Wn5JyZHXAol5
There are 4 parts - id : y (yescrypt) - param : j9T - salt : PaFEMV0mbpeadmHDv0Lp31 - hash : G/LliR3MqgdjEBcFC1E.s/3vlRofsZ0Wn5JyZHXAol5 **Q:** 1. What does j9T in param field mean? 2. Are there other options in this field? 3. Where can we find official documentation? I've seen this question; The format of encrypted password in /etc/shadow , however, there is no explanation there.
kelalaka (195 rep)
Feb 14, 2022, 10:50 PM • Last activity: Nov 12, 2022, 08:56 AM
0 votes
1 answers
137 views
Hashed passwords are NOT similar although the salt and password are similar
I had created two users on Linux with the same exact passwords, but when I looked at the `/etc/shadow` file, I found that the hashed values look different, although the salt file is the same. (Please see below, `j9T` is the salt). Why the hashed passwords are NOT similar, although the slat and passw...
I had created two users on Linux with the same exact passwords, but when I looked at the /etc/shadow file, I found that the hashed values look different, although the salt file is the same. (Please see below, j9T is the salt). Why the hashed passwords are NOT similar, although the slat and password are similar? # tail /etc/shadow Bob:$y$**j9T**$ewJ0HB756BZDnPjx7zzbm0$i39AKrfuQuvvoQJpujwWd7Z4bcZgN1l0IWeJsNmLzg7:19254:0:99999:7::: Bob:$y$**j9T**$pFF5c93UZvdFYD2nanxEO.$SMhaxtPUPEUZdZZx.b1tGmjXgM67nqBJgMk2sNP.5s4:19254:0:99999:7:::
David Nicola (3 rep)
Sep 19, 2022, 04:00 PM • Last activity: Sep 19, 2022, 04:57 PM
-1 votes
1 answers
281 views
How to get user creation details
Kindly assist to to get user creation details (date and time) and users login details in Solaris 10
Kindly assist to to get user creation details (date and time) and users login details in Solaris 10
eliot (31 rep)
Aug 8, 2022, 10:03 AM • Last activity: Aug 8, 2022, 10:46 AM
12 votes
1 answers
37107 views
The format of encrypted password in `/etc/shadow`
I see a hashed passphrase like the following in `/etc/shadow`. I don't quite understand its format. ``` $y$j9T$F5Jx5fExrKuPp53xLKQ..1$X3DX6M94c7o.9agCG9G317fhZg9SqC.5i5rd.RhAtQ7 ``` It is made of four parts as shown below. According to `crypt(5)`, `y` means `yescrypt`. https://manpages.debian.org/un...
I see a hashed passphrase like the following in /etc/shadow. I don't quite understand its format.
$y$j9T$F5Jx5fExrKuPp53xLKQ..1$X3DX6M94c7o.9agCG9G317fhZg9SqC.5i5rd.RhAtQ7
It is made of four parts as shown below. According to crypt(5), y means yescrypt. https://manpages.debian.org/unstable/libcrypt-dev/crypt.5.en.html
- y
- j9T
- F5Jx5fExrKuPp53xLKQ..1
- X3DX6M94c7o.9agCG9G317fhZg9SqC.5i5rd.RhAtQ7
What is the meaning of the last three parts?
user15502206 (229 rep)
Mar 29, 2021, 03:47 AM • Last activity: Jun 29, 2022, 01:05 AM
Showing page 1 of 20 total questions