Generate strong random passwords with openssl rand

Cryptographically secure passwords from a tool you already have — no pwgen or keychain needed.

LinuxrandompasswordopensslLow risk
Run `openssl rand -base64 24` to get a 24-byte (192-bit) random value encoded in base64 as a strong password.

01Command

Command
$ openssl rand -base64 24

02What it does

The number is bytes of entropy, not characters: `-base64 24` yields 32 base64 characters carrying 192 bits of entropy, comfortably above any modern recommendation. Use `-hex 16` when the consumer can't handle base64's `+/=` characters (some APIs and WiFi passwords), or pipe through `tr -d '/+=' | cut -c1-20` to shape the output. Because it draws from the OS CSPRNG, this is suitable for API keys, DB passwords, and JWT secrets — not for GPG-style key material, which should come from `openssl genpkey`.

03Risk

RiskLow risk
Requirementsopenssl

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Security & Privacy