Created
December 4, 2014 10:07
-
-
Save ik5/2efb7baa5144ecfbdf2f to your computer and use it in GitHub Desktop.
random password generator in shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
genpasswd() { | |
local l=$1 | |
[ "$l" == "" ] && l=20 | |
tr -dc "A-Za-z0-9_%^&*()\`/[]{}|" < /dev/urandom | head -c ${l} | xargs | |
} | |
genpasswd 52 |
for additional chars:
`genpasswd() {
local l=$1
strings /dev/urandom | grep -o '[[:print:]]' | head -n ${l} | tr -d '\n'; echo
}
`
there are also powerful command line generators like "apg" (advanced password generator).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is mine:
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo