Password generator

A simple password generator complementary to EPM. It relies on /dev/urandom for password generation, which should provide a good enough randomness for safe passwords.


Usage of is as easy as calling the script:

$ passgen

By default it generates as password of 30 characters long, using nearly all symbols that are available on a standard US-layout keyboard. If we would like a different password length, we can do so by the -n flag:

$ passgen -n 20

This is helpful for websites that feature a stupidly low password length limitation. Coincidentally the same websites typically are picky on the used characters as well. It is advisable to make a copy of passgen for this, and update the call to tr -cd ... to match the requirements (see source below).




usage () {
cat <<USAGE
Usage: passgen [-n LENGTH]

    -l  Specify the length of generated password in characters.

O=`getopt -n passgen -o 'n:h' -- "$@"` || exit 1
eval set -- "$O"
while true; do
    case "$1" in
        -n) length="$2"; shift 2;;
        -h) usage;;
        --) shift;;
        *)  break;;

tr -cd 'a-zA-Z0-9!@#$%^&*()_\-+=\[\]\{\}:;<>,./\?' < /dev/urandom | head -c $length

Download the source


Passgen is trivial, and thus in public domain.