Skip to content

Instantly share code, notes, and snippets.

@ksaver
Created May 26, 2020 10:22
Show Gist options
  • Save ksaver/43010062708bae3effbd5a91ac533d23 to your computer and use it in GitHub Desktop.
Save ksaver/43010062708bae3effbd5a91ac533d23 to your computer and use it in GitHub Desktop.
Generate random passwords from bash command line.
# Generate random passwords from bash command line.
function random_passwd() {
LENGHT=${1:-16}
cat /dev/urandom |tr -dc 'A-Za-z0-9@#$%&()=-_?!+*{[]}' \
| fold -w $LENGHT \
| head -n 3 # shows 3 passwords
echo
}
random_passwd 24 # 24 characters long password
random_passwd # default 16 chars long
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment