Skip to content

Instantly share code, notes, and snippets.

@einarjh
Created November 11, 2014 14:30
Show Gist options
  • Save einarjh/d583a340798464199ab8 to your computer and use it in GitHub Desktop.
Save einarjh/d583a340798464199ab8 to your computer and use it in GitHub Desktop.
make temporary password in bash
# Explanation haiku:
# semi-random temp password
# easy to remember, type
# not very secure
function maketemppassword() {
part1="$(awk 'length==8' /usr/share/dict/words | grep -v '[^[:alpha:]]' | shuf -n 1 | tr '[:upper:]' '[:lower:]')"
part2="$(< /dev/urandom tr -dc 0-9 | head -c${1:-2};echo;)"
part3="$(< /dev/urandom tr -dc A-Z | head -c${1:-2};echo;)"
echo "${part1}-${part2}_${part3}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment