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

Solution Verified - Updated -

Issue

  • 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.

Environment

  • Red Hat Enterprise Linux 8
  • 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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content