Sample Header Ad - 728x90

How to pass a salt to mkpasswd with yescrypt algorithm

5 votes
1 answer
1317 views
I am trying to verify this hashed password from my /etc/shadow file: $y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90 I would like to pass the hash to mkpasswd this way but it fails:
$ mkpasswd -m yescrypt secret eia4V8bEUD9QBJAEwilXU.
Wrong salt length: 22 bytes when 0 expected.

$ mkpasswd -m yescrypt secret "$y$j9T$eia4V8bEUD9QBJAEwilXU.$"
crypt: Invalid argument
How can I pass the salt or parameters from the hashed string? By the way, I have found a way to verify the password with a python script as described in [this SO post](https://unix.stackexchange.com/a/707733/610218) , so it means we have enough info (parameters and salt) to compute the hash. But I would prefer to do it with mkpasswd:
$ python3 -c 'import crypt, os; print(crypt.crypt("secret", "$y$j9T$eia4V8bEUD9QBJAEwilXU.$"))'
$y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90
Asked by Louis Coulet (153 rep)
May 8, 2024, 11:38 PM
Last activity: May 9, 2024, 12:03 AM