Generate Random Passwords with openssl rand
Produce cryptographically secure random bytes encoded as base64 or hex — a built-in password generator hiding in every Linux install.
Run openssl rand -base64 18 for a 24-character password, or openssl rand -hex 32 for a 64-character hex string suitable for API keys.
01Command
Command
$ openssl rand -base64 18
openssl rand -hex 3202What it does
openssl rand draws from the system CSPRNG and outputs raw bytes; the -base64 and -hex flags just change the encoding, so the byte count is the real entropy budget: 18 base64-encoded bytes give 144 bits of entropy in 24 printable characters. -hex 32 produces 256-bit values that are the standard size for encryption keys and secrets. Pipe through tr -d '/+=' if a particular password policy forbids punctuation.
03Risk
!Warning: base64 output can include / and + characters that break URLs and some shells — know your consumer's character rules, or use -hex for guaranteed alphanumerics.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- openssl(1) — Linux man pageEvidence: openssl man page: 'openssl rand - generate pseudo-random bytes' with -base64 and -hex output encoding options.
Last verified: 2026-09-17 · Category: Security & Privacy