Generate Strong Random Passwords on Linux with pwgen, OpenSSL, and GPG

Learn how to create high‑entropy, hard‑to‑guess passwords on Linux using three command‑line tools—pwgen, OpenSSL, and GPG—covering installation, usage options, batch generation scripts, and additional utilities for secure credential management.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Generate Strong Random Passwords on Linux with pwgen, OpenSSL, and GPG

In an era of frequent data breaches, strong passwords are the first line of defense for personal and professional accounts. This guide presents three practical command‑line methods to generate high‑strength passwords that include uppercase, lowercase, digits, and symbols.

1. pwgen

Installation

Debian/Ubuntu: sudo apt install pwgen RHEL/CentOS: sudo yum install pwgen Basic usage

Running pwgen without options produces 160 passwords (8 characters each) that are relatively easy to remember.

To generate a specific number and length, use: pwgen -s 14 5 For extremely random passwords, add the -cnys flag:

pwgen -cnys 14 20

2. OpenSSL

The openssl rand -base64 command can create a single 14‑character password: openssl rand -base64 14 To generate multiple passwords, wrap the command in a simple shell loop:

for pw in {1..4}; do openssl rand -base64 14; done

3. GPG (GnuPG)

GPG can produce random base64‑encoded strings suitable as passwords: gpg --gen-random --armor 1 14 Batch generation also requires a loop, similar to OpenSSL:

for pw in {1..4}; do gpg --gen-random --armor 1 14; done

Conclusion

Strong passwords are essential for account security. Besides pwgen, OpenSSL, and GPG, other utilities such as makepasswd and mkpasswd can also generate high‑entropy passwords. Choose the tool that best fits your workflow and automate batch creation with simple shell scripts.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

OpenSSLShell scriptingpassword generationGPGpwgen
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.