Script to generate passwords

When I need to generate temp passwords for users, I prefer simple alpha numeric passwords. If enough characters are used, they should be strong enough for most uses. Here's a little script I use to generate them:


if [ -z "$1" ]; then c=20; fi
cat /dev/urandom | tr -cd [:alnum:] | head -c "$c" | xargs

Example output:

$ genpasswd 8

If length is unspecified, defaults to 20:

$ genpasswd

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).