Skip to content

Instantly share code, notes, and snippets.

@sahal
Created November 23, 2014 19:48
Show Gist options
  • Select an option

  • Save sahal/3c2a0831e76e2a85a434 to your computer and use it in GitHub Desktop.

Select an option

Save sahal/3c2a0831e76e2a85a434 to your computer and use it in GitHub Desktop.
Generate a list of passwords using /dev/urandom or /dev/random and bash
#!/bin/sh -e
# by Sahal Ansari - github@sahal.info
# based on this blog post by Kevin Goodman
# http://blog.colovirt.com/2009/01/07/linux-generating-strong-passwords-using-randomurandom/
# NOTE: install haveged for faster/'better' results!
length=24
count=10
random_source="/dev/urandom"
#random_source="/dev/random"
#alpha-numeric-special chars
chars="a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?="
#alpha-numeric
#chars="a-zA-Z0-9"
cat "$random_source" | tr -dc "$chars" | fold -w "$length" | head -n "$count"| grep -i '[!"$chars"]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment