I wanted a CLI-based strong password generator for Linux. mkpasswd is nice, but I wanted something more flexible. I didn’t like having to provide my own character sequence. I wanted something with a built-in character sequence generator with an easy way to control the likelihood of numbers and symbols. I wanted something that could read in a character sequence from a file or standard input. And I wanted something that not only had sensible default values, but was easily configurable. It was one of those times where searching for such a tool was a bigger hassle than writing my own. So I opened up vim and got to work. The result is a Python-based password generator called mkstrongpw.

mkstrongpw can generate a character sequence based on four character categories: lowercase letters, uppercase letters, numerical digits, and non-alphanumeric symbols. By default, the likelihood (or odds) of each character type is as follows: lowercase: 5/10; uppercase: 2/10; digits: 2/10; symbols: 1/10. These values can be easily changed via command line options. A single, non-option argument can be passed, specifying a filename to be read in as the character sequence. If this argument is a single hyphen (-), standard input is used. Newlines and whitespace are stripped from the beginning and end of each line of the input file.

By default, mkstrongpw uses its built-in sequence generator to produce 10 passwords, 8 characters in length. Command line options can be used to modify these values. Take a look at the following examples:

Default operation (no arguments):

$ mkstrongpw
x5mHpZum
zc{onlKH
O5WlkYaV
i&hgb?pX
cjw0Gjni
aVtxjuve
aDeVHym8
1SDWKhEr
U3Kja!<z
]tzwmog7

Generate 1 password, 10 characters in length:

$ mkstrongpw -n1 -c10
nWnf46mZRd

Generate a character sequence using `dd` and `uuencode`:

$ dd if=/dev/urandom bs=1 count=1024 2>/dev/null | uuencode - | mkstrongpw -
+DTS@]B\
C>R60'&9
6X])H$(,
GP7_^9\(
FM;^)84F
E)RGR4+[
`<1^_NT_
8":\7%R-
DJSLJ*I`
=MQ^]2D9

That’s a broad overview of mkstrongpw. Use the --help option for more details.

Get it