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

2 Answers 2


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
  • 6
    +1 for whois package name for installation.
    – Arda
    Commented Jan 28, 2016 at 16:53
  • 2
    For clarification, PASSWORD is your desired password and the SALT, explained here: en.wikipedia.org/wiki/Salt_%28cryptography%29 can be omitted. Commented Feb 26, 2016 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. Commented Mar 8, 2018 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). Commented Mar 9, 2018 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. Commented Apr 24, 2019 at 15:33

Python 2:

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

Python 3:

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


perl -e 'print crypt("password","\$6\$saltsalt\$") . "\n"'
  • 2
    For Python 2.7 and 3.3: python -c 'import crypt,getpass; print(crypt.crypt(getpass.getpass(), crypt.mksalt(crypt.METHOD_SHA512)))' Commented Sep 30, 2014 at 11:44
  • 1
    @CristianCiupitu: crypt.mksalt() is not in Python 2.7, only 3.3 onwards. Commented Jun 17, 2015 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
    Commented Jun 17, 2015 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. Commented Jun 17, 2015 at 22:55
  • 1
    @CraigMcQueen, yes, you're right, it seems it has been backported in the python package for Fedora 20. Commented Jun 18, 2015 at 13:25

Not the answer you're looking for? Browse other questions tagged .