2

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, 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

1 Answer 1

3

If you pass the salt (eg with -S or as the second param) and include the $ settings then you don't need to specify the method

% mkpasswd -S '$y$j9T$eia4V8bEUD9QBJAEwilXU.' secret
$y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90

% mkpasswd secret '$y$j9T$eia4V8bEUD9QBJAEwilXU.'       
$y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90
1
  • 1
    Thank you, I also notice that my mistake was using double quotes instead of single quotes ! May 9 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .