Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 7, 2019 02:29
Show Gist options
  • Save o0-o/3e550bfaf08fb70ce1e50b133affab8e to your computer and use it in GitHub Desktop.
Save o0-o/3e550bfaf08fb70ce1e50b133affab8e to your computer and use it in GitHub Desktop.
[Generate Password] Generate a long random password #Shell
# password.sh
declare -r length=$(($(($RANDOM%17))+23)) 2>/dev/null && #23-39
( #openssl
openssl rand -base64 "${length-32}" ||
#os random
base64 < /dev/urandom |
fold --width="${length-32}" |
head -n 1
) 2>/dev/null ||
exit 1 #failure
exit 0 #success
#https://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment