Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Last active August 28, 2020 23:37
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 mahemoff/052e9ada53aaabfde3da0ca6ee4026c1 to your computer and use it in GitHub Desktop.
Save mahemoff/052e9ada53aaabfde3da0ca6ee4026c1 to your computer and use it in GitHub Desktop.
Generate a strong password in bash

A wrapper for pwgen. Put this in your ~/.bashrc to generate a long & strong password. You can append an optional message to remind yourself of the purpose if you can't immediately transfer it to a credentials repository.

Example usage:

$ hardpass
ZzVMh:u(?ln134`q&PW9rmM0h]rRQ6p-#tv\3I.7
$ hardpass
OXX]k%e1/o-njU0XIK'UT@=\,9OeUGOr
$ hardpass new twitter password
### new twitter password
z9jcHhN@wwj2U':FTGP*bFsKb"<:
function hardpass {
message=$1
length=$(( 28 + RANDOM % 16 ))
if [ "$message" != "" ]; then
echo "### $message"
fi
pwgen -1 -y -s $length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment