Ssl passwd

ssl_passwd_hash

Generate a hashed password string suitable for /etc/shadow or htpasswd. This is distinct from secrets_genpasswd, which generates random plaintext passwords. Here the input is a known password; the output is the shadow-compatible hash.

Supported algorithms (passed as $1): -1 MD5-crypt (legacy, avoid where possible) -apr1 Apache MD5-crypt (htpasswd compatible) -5 SHA-256-crypt -6 SHA-512-crypt (default; preferred for /etc/shadow on modern Linux)

If no password is given, openssl prompts interactively (input is not echoed).

Example

ssl_passwd_hash                          # prompts, SHA-512-crypt
ssl_passwd_hash -6 "mysecret"
ssl_passwd_hash -apr1 "htpassword" abc123

Arguments

  • $1 (string): Algorithm flag (default: -6)
  • $2 (string): Password to hash (optional; prompts if omitted)
  • $3 (string): Salt string (optional; openssl generates a random salt if omitted)

Exit codes

  • 0: Success
  • 1: openssl error

Output on stdout

  • Hash string in crypt(3) format