19

I am using this function to create a password in the shadow file

$ mkpasswd -m sha-512 password
$6$o50n4EfNOBzfs$K5l5AcOI5e0I9n2df0LmR11OLSPKSVM6AGBOnWVfDDfMubb46MrAj0zehdLNEoYzD2fj5q4XUdDwexj/dWLHy/
$ mkpasswd -m sha-512 password
$6$ADmDOhDpW$gsYQuiKPpV1ewaUpRq2VGAvrcocffLQ8XGF94e6LNLZfKIjy6Ku.cZoR/5exeCi1ESjPB9TRM6HxCiY5BCNCV0
$ mkpasswd -m sha-512 password
$6$Efj1agaI$HGkny3q1OTYT4KREh18gueHJae/3Bvil0iOEhfXj8bD.qy9Lg2UIQJMuBcq0XtG3xzueK.7cp0GfKr7tEo5YI/
$ mkpasswd -m sha-512 password
$6$zdVPlCPai4Y$x3CBvlP99xZXZcr4PTiE..YLpZx39h5OHDxqazd9wFLImPuwsXF0M6KmqLzlCCrnQhI2lmEPdCzfmHA/fDiOz.

It makes me wonder how does the output value work as a password

3

1 Answer 1

32

If you check the manpage with "man mkpasswd", you will see that that command also accepts an optional parameter -S, --salt=STRING If you omit it, it will use a random salt value, and therefore the encrypted password value will also be different.

If you provide the salt,

mkpasswd -m sha-512 password -s "11223344"
$6$11223344$YzaRt.fnidpXmKw.Dl20htfOrJ8X2Yx3V.h5zUlhlN2SdczempQmQcDcMYd6mHiXlaMqyGt200zDwuZiC8ZZw1

you always get the same result.

By the way, you can see the salt value at the very beginning of the output string: it is the value between $'s and 8 to 16 chars long.

You must log in to answer this question.

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