Skip to content

Instantly share code, notes, and snippets.

@ik5
Created December 4, 2014 10:07
Show Gist options
  • Save ik5/2efb7baa5144ecfbdf2f to your computer and use it in GitHub Desktop.
Save ik5/2efb7baa5144ecfbdf2f to your computer and use it in GitHub Desktop.
random password generator in shell
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc "A-Za-z0-9_%^&*()\`/[]{}|" < /dev/urandom | head -c ${l} | xargs
}
genpasswd 52
@tomer
Copy link

tomer commented Dec 8, 2014

Here is mine:
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo

@ik5
Copy link
Author

ik5 commented Dec 8, 2014

for additional chars:
`genpasswd() {
local l=$1
strings /dev/urandom | grep -o '[[:print:]]' | head -n ${l} | tr -d '\n'; echo
}

`

@boazrymland
Copy link

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