Skip to content

Instantly share code, notes, and snippets.

@timkuijsten
Last active February 22, 2017 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timkuijsten/5271873 to your computer and use it in GitHub Desktop.
Save timkuijsten/5271873 to your computer and use it in GitHub Desktop.
Generate strong and easy to type passwords. Tested with OpenBSD 5.2, Ubuntu 10.04, Ubuntu 12.04 and Mac OS X 10.8.
#/bin/sh
# copy to /usr/local/bin
# usage: genpass [length]
LENGTH=12
if [ 0 -lt $(($1)) ]; then
LENGTH=$1
fi
# extract enough bytes from the random number generator
dd bs=$((80*$LENGTH)) count=1 if=/dev/random 2>/dev/null | LC_CTYPE=C tr -cd 'ABCDEFGHJKLMNPQRSTUVWXYZ' | cut -b 1-$LENGTH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment