Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Last active Aug 28, 2020
Embed
What would you like to do?
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