sha1 password hash linux sha1 password hash linux linux linux

sha1 password hash linux


I know this is really old but here is why it did not work and what to do about it:

When you run the

echo -n "hello" | sha1sum

as in your example you get

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d  -

Notice the '-' in the end.

The hash in front is the correct sha1 hash for hello, but the dash messes up the hash.

In order to get only the first part you can do this:

echo -n "hello" | sha1sum | awk '{print $1}'

This will feed your output through awk and give you only the 1st column.Result: The correct sha1 for "hello"

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

Hope this helps someone.


echo -n YOUR_TEXT | sha1sum | awk '{print $1}'

exchange YOUR_TEXT with the text you have to hashing it.


The password format may be different in different applications. For example, for /etc/passwd you can generate a SHA-256 password with:

# perl -e 'print crypt("password", q($5$salt$)), "\n";'$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1#

For passwords in LDAP (e.g. for slapd.conf), it may be:

# slappasswd -h "{SSHA}"New password:Re-enter new password:{SSHA}bjEe8dPBjyecc7hD1kUhxQUdF9dt4Hya#

You need to know the exact password format for your application and how the passwords are generated.