Skip to content

Instantly share code, notes, and snippets.

@brianonn
Created January 2, 2016 16:52
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 brianonn/cf7bb2e237fc37df8f04 to your computer and use it in GitHub Desktop.
Save brianonn/cf7bb2e237fc37df8f04 to your computer and use it in GitHub Desktop.
SH: function for making random passwords
## put this into your ~/.bashrc file and make random passwords as needed.
##
## usage:
## mkpw <length>
##
## ex: for for i in $(seq 5);do mkpw 10 ; done
## Rw3QPaeUM2
## qPgQnx5K38
## wZnOZjQsdN
## H0tcr1tVrQ
## w3xnyY00lp
mkpw()
{
[ $# -eq 0 ] && len=16 || len="$1"
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w "$len" | head -1
}
@brianonn
Copy link
Author

brianonn commented Jan 2, 2016

Todo: I could enhance this with some options:

-l length - make passwords of length length
-n count - create count passwords

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment