In /etc/shadow file there are encrypted password.

Encrypted password is no longer crypt(3) or md5 "type 1" format. (according to this previous answer) Now I have a


as entry.

I can no longer use

 openssl passwd -1 -salt salt hello-world

to generate encrypted passwd.

Any equivalent like (non existing) .. ?

 openssl passwd -6 -salt salt hello-world


python -c 'import crypt; print crypt.crypt("password", "$6$saltsalt$")'

(for python 3 and greater it will be print(crypt.crypt(..., ...)))


perl -e 'print crypt("password","\$6\$saltsalt\$") . "\n"'
| improve this answer | |
  • 1
    For Python 2.7 and 3.3: python -c 'import crypt,getpass; print(crypt.crypt(getpass.getpass(), crypt.mksalt(crypt.METHOD_SHA512)))' – Cristian Ciupitu Sep 30 '14 at 11:44
  • 1
    @CristianCiupitu: crypt.mksalt() is not in Python 2.7, only 3.3 onwards. – Craig McQueen Jun 17 '15 at 5:59
  • 4
    Remember that command line arguments are visible to other users via ps. When working with real passwords, don't use these commands as written; instead turn them into a script that reads the password from stdin or a file. – Jander Jun 17 '15 at 7:46
  • 1
    @CristianCiupitu: Python 2.7.8 in Ubuntu 14.10 doesn't have it. The Python 2 docs don't document it. The Python 3 docs say it's new in 3.3. – Craig McQueen Jun 17 '15 at 22:55
  • 1
    @CraigMcQueen, yes, you're right, it seems it has been backported in the python package for Fedora 20. – Cristian Ciupitu Jun 18 '15 at 13:25

On Debian-based systems you can use mkpasswd.

mkpasswd -m sha-512 PASSWORD [SALT]

(PASSWORD is your desired password; SALT is optional.)

Strangely, that tool is found in the whois package.

sudo apt-get install whois
| improve this answer | |
  • 4
    +1 for whois package name for installation. – Arda Jan 28 '16 at 16:53
  • 1
    For clarification, PASSWORD is your desired password and the SALT, explained here: en.wikipedia.org/wiki/Salt_%28cryptography%29 can be omitted. – harperville Feb 26 '16 at 14:23
  • Is there a command to check if mkpasswd's generated hash is correct? I'm generating it and it constantly fails after I put it in /etc/shadow. – CMCDragonkai Mar 8 '18 at 5:57
  • I'm sure the generated hash would be correct, and your problem would be in something else. But, to verify it, you could generate the hash using an independent implementation of the hash (such as one of the other answers to this question). – Craig McQueen Mar 9 '18 at 1:28
  • It looks like if SALT is not specified, mkpasswd generates a random one for you. Otherwise, mkpasswd expects the SALT to be between 8 and 16 bytes inclusively. – Nicholas Sushkin Apr 24 '19 at 15:33

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