Generate passwords in Linux

I needed a way to generate random strings to be used for an API Key.

There are online password/hash generators however as they are online I’m hesitant to use them as they can store generated strings. Not great when you want to be as secure as possible to prevent data breaches on your web server.

Install pwgen

The following install is for Ubuntu using the APT package manager, this application should be installable in most Linux distributions package managers.

sudo apt install pwgen

Usage

Running the pwgen will generate a collection of 160 passwords with each being eight characters long.

pwgen

To output a single password add the -1 flag.

pwgen -1

To change the character length for each password use the -y flag followed by the character count.

pwgen -1 -y 30

To include at least one capitalized letter use the -c flag.

pwgen -1 -y 30 -c