Skip to content

Instantly share code, notes, and snippets.

@mnem
Created January 5, 2012 20:07
Show Gist options
  • Save mnem/1566984 to your computer and use it in GitHub Desktop.
Save mnem/1566984 to your computer and use it in GitHub Desktop.
Quick 'n' dirty password generation commands for *nix/mac
# Will generate passwords up to 76 characters long.
#
# Change the 20 at the end to change the length.
dd if=/dev/urandom count=1 2> /dev/null | base64 | sed -ne 2p | cut -c-20
# Will generate passwords up to 40 characters long. Only uses hex characters
# if symbols freak you out.
#
# Change the 20 at the end to change the length.
dd if=/dev/urandom count=1 2> /dev/null | sha1sum | cut -c-20
# Will generate passwords of any length. Must have openssl installed.
#
# Change PW_LENGTH=20 at the start to specify the length.
PW_LENGTH=20; openssl rand -base64 $PW_LENGTH | tr -d '\n=' | cut -c-$PW_LENGTH
# Will generate passwords of any length. Must have openssl installed. Only
# uses hex characters if symbols freak you out.
#
# Change PW_LENGTH=20 at the start to specify the length.
PW_LENGTH=20; openssl rand -hex $PW_LENGTH | cut -c-$PW_LENGTH
@mnem
Copy link
Author

mnem commented Jan 5, 2012

Lots of lovely hacky single line randomish password generators.

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