Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been wondering for a while, why does running "echo 'helloworld' | openssl passwd -1 -stdin" yield different results every time?If I put any of the hashes in my /etc/shadow I can use them as my password and login to my system, how does it work?

computer:/ user$ echo 'helloworld' | openssl passwd -1 -stdin
$1$xlm86SKN$vzF1zs3vfjC9zRVI15zFl1
computer:/ user$ echo 'helloworld' | openssl passwd -1 -stdin
$1$/0.20NIp$pd4X9xTZ6sF8ExEGqAXb9/
computer:/ user$ echo 'helloworld' | openssl passwd -1 -stdin
$1$sZ65uxPA$pENwlL.5a.RNVZITN/zNJ1
computer:/ user$ echo 'helloworld' | openssl passwd -1 -stdin
$1$zBFQ0d3Z$SibkYmuJvbmm8O8cNeGMx1
computer:/ user$ echo 'helloworld' | openssl passwd -1 -stdin
$1$PfDyDWER$tWaoTYym8zy38P2ElwoBe/

I would think that because I use this hash to describe to the system what my password should be, I should get the same results every time. Why don't I?

share|improve this question
3  
If they were the same each time, an attacker could just hash billions of common passwords and easily check for them. –  David Schwartz Jun 8 '13 at 21:25
add comment

1 Answer

up vote 33 down vote accepted

They all have a different salt. A unique salt is chosen each time, as salts should never be reused. Using a unique salt for each password makes them resistant to rainbow table attacks.

share|improve this answer
7  
6  
It might be a good idea to mention that the output includes the salt after the $1$ (the dollar symbols are separators). –  poke Jun 9 '13 at 11:07
5  
So in the hash of '$1$xlm86SKN$vzF1zs3vfjC9zRVI15zFl1' xlm86SKN is the salt and vzF1zs3vfjC9zRVI15zFl1 is the hash of salted helloworld? –  Peter Jun 9 '13 at 18:44
2  
@Peter: exactly. –  Joachim Sauer Jun 10 '13 at 6:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.