How to Generate Strong Linux Passwords and Verify Their Strength
This tutorial explains how to create complex, high‑entropy passwords on Linux using GPG or OpenSSL, optionally filter out special characters with sed, and then assess password strength with the cracklib‑check tool on CentOS 8, illustrating both weak and strong examples.
Strong passwords should combine letters, numbers, and symbols while avoiding known words, birth dates, or personal names to resist dictionary attacks. Although there is no strict length rule, passwords longer than 16 characters are generally recommended.
On a Linux system with gpg installed, you can generate a random password using the --gen-random and --armor options. For example:
[root@localhost ~]# gpg --gen-random --armor 2 12
zXVKRoB0/V4BN9QGIf you prefer a password without special characters, pipe the output through sed to remove anything that is not a letter or digit:
[root@localhost ~]# gpg --gen-random --armor 2 12 | sed 's/[^a-zA-Z0-9]//g'
n4ciIlRLkLTkzwgThe same approach works with openssl. Generate a base‑64 string and optionally filter it:
[root@localhost ~]# openssl rand -base64 12
QIrH/PLXqzmLuI/a [root@localhost ~]# openssl rand -base64 12 | sed 's/[^a-zA-Z0-9]//g'
lXIg4cKLCLVvsiTo evaluate password strength, install the cracklib utility on CentOS 8: [root@localhost ~]# yum -y install cracklib Testing a simple dictionary‑based password shows it is rejected:
[root@localhost ~]# echo "a1b2c5" | cracklib-check
a1b2c5: it is based on a dictionary wordAnother example with a common word also fails:
[root@localhost ~]# echo "Administrator" | cracklib-check
Administrator: it is based on a dictionary wordFinally, test a generated password; the tool reports it as acceptable:
[root@localhost ~]# openssl rand -base64 12 | cracklib-check
VdBlmvIgGY4ehWly: OKThese commands demonstrate how to produce high‑entropy passwords and verify that they meet basic security criteria using standard Linux tools.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
