LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to create shadow pasword hash manually? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-shadow-pasword-hash-manually-838069/)

Dims 10-14-2010 12:05 PM

How to create shadow pasword hash manually?
 
How to create the password hash exactly the same as in shadow file (from the command line)?

The command

openssl passwd -crypt

returns something different.

luvshines 10-14-2010 12:12 PM

Looking for this ??
http://www.linuxquestions.org/questi...d-hash-602739/

Dims 10-14-2010 12:20 PM

Quote:

Originally Posted by luvshines (Post 4127412)
Looking for this ??

Thanks! Already found this and understood about the salt, but I have not $1 at the beginning of the hash, but $6 and my hash from shadow file is much longer, than one from openssl (approx 86 characters long).

Dims 10-14-2010 12:25 PM

I found that $6 means SHA encryption, but then I can't find "salt" option in "openssl sha" command...

Dims 10-14-2010 02:00 PM

The following command worked:

python -c "import crypt, getpass, pwd; print crypt.crypt('<PASSWORD>', '\$6\$<SALT>\$')"

Dims 10-14-2010 02:09 PM

Does anyone know, how SALT is integrated into password?

I have failed to implement encoding myself with the following sequence:

1) concatenate password + salt
2) convert to ASCII bytes
3) perform SHA512 hashing
4) create base64 string

I think salt concatenating is somehow wrong...

jschiwal 10-14-2010 07:01 PM

The pwdutils package should supply the mkpasswd program.

The results of "mkpasswd -S <salt_string> -m sha-512" is an 86 digit long string, after the type and salt.

echo -n 'ThisIsATest' | /usr/bin/mkpasswd -m sha-512 -S 'salt1234' -
$6$salt1234$GCfgodngkLAgi8qKn2jCRmzXVF.ZSxa3Pj3bWQJpcxFU.6/YFfwB4LQl26rrs7/nCXTul.6nqDclAp/ki4Jz40

Some distro's use the blowfish hash by default (see man 3 crypt) however, I don't believe that mkpasswd supports blowfish.


All times are GMT -5. The time now is 12:19 PM.