Skip to content

Instantly share code, notes, and snippets.

@lavoiesl
Created September 10, 2012 03:55
Show Gist options
  • Save lavoiesl/3688791 to your computer and use it in GitHub Desktop.
Save lavoiesl/3688791 to your computer and use it in GitHub Desktop.
Generates a random password using only non-ambiguous alphanumeric characters
#!/bin/bash
# Generates a random password using only non-ambiguous alphanumeric characters
# Usage: genpasswd.sh [length]
length=16
if [[ -n "$1" ]]; then
length="$1"
fi
head -c $(( 2 * $length)) /dev/urandom | base64 | sed -E 's/[^23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]//g' | head -c $length
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment