Skip to content

Instantly share code, notes, and snippets.

@rnkoaa
Created August 14, 2020 13:37
Show Gist options
  • Save rnkoaa/ce2d97c27398928de0116fad940a6ba7 to your computer and use it in GitHub Desktop.
Save rnkoaa/ce2d97c27398928de0116fad940a6ba7 to your computer and use it in GitHub Desktop.
generate random password on cli
#!/bin/bash
LENGTH=25
if [ ! -z "$1" ] && [ $1 -gt 1 ]; then
LENGTH=$1
fi
NUMBYTES=`echo $LENGTH | awk '{print int($1*1.16)+1}'`
openssl rand -base64 $NUMBYTES | tr -d "=+/" | cut -c1-$LENGTH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment