Generate Strong Passwords

By | 2011/01/24

How can I generate strong passwords from the command line?

The excellent program apg is fantastic for generating all sorts of passwords.

1. Install apg:

$ sudo apt-get install apg

2. Then you can simply run

$ apg

…which will run default options and give something like this:

stmiller@li166-66:~$ apg

Please enter some random data (only first 8 are significant)
(eg. your old password):>
Evnupthyac6 (Ev-nup-thyac-SIX)
AsofMiWor7 (As-of-Mi-Wor-SEVEN)
Plotyujpak4 (Plot-yuj-pak-FOUR)
OwIvnupel8 (Ow-Iv-nup-el-EIGHT)
ladjothPeg4 (lad-joth-Peg-FOUR)
cluHosoys5 (clu-Hos-oys-FIVE)

Customize options as desired like:

$ apg -a 1 -m 16 -M SNCL -n 1

-a 1 = random (un-pronounceable password)
-m 16 = 16 characters in length
-M SNCL = use Special symbol, Number, Capital, and Lowercase
-n 1 = generate 1 password

The above command gives me this, for a random (pun) example:


Obviously you can customize the command line options to fit your desired password requirements!

[More info on apg]