How to generate a SHA-2 (sha256 or sha512) hashed password compatible with /etc/shadow

Solution Verified - Updated -


  • Using the method detailed in this Red Hat Magazine article works great to generate /etc/shadow-compatible md5-hashed passwords, but what about SHA-256 or SHA-512? The openssl passwd --help command only mentions MD5.

  • How can I generate a hashed password for /etc/shadow?

  • Need to hash a passphrase like crypt() does, with SHA512.


  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.