Although BitWarden, my password manager of choice, offers a really convenient option for generating super strong passwords, sometimes I prefer to generate such passwords right from the comfort of the command line. There are two fine tools I tend to use for that: bw and pwgen. The former I keep on my MacBook, and I installed bitwarden-cli, the package which contains bw, with the help of Homebrew. The latter I have it on a couple of Linux machines, and on each one of those I installed package pwgen with the help of the respective package manager.

To generate a password with bw you type something like this:

bw generate -nuls --length 32

The parameter --length is self-explanatory, so let us take a look at the options:

  • -n include numeric characters
  • -u include uppercase characters
  • -l include lowercase characters
  • -s include special characters

Get detailed help on the password/passphrase generation capabilities of bw:

bw generate --help

Generating strong passwords with pwgen is just as easy:

pwgen -sync -B 32 1

In the example above the rightmost number (1) says to pwgen that we only want one password, while the second number from the right (32) specifies the length of the password. And now for some options:

  • -s generate completely random passwords
  • -y include at least one special symbol in the password
  • -n include at least one number in the password
  • -c include at least one capital letter in the password
  • -B do not include ambiguous characters in the password

Of course, you may type

pwgen --help

to see all available options.