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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0