Skip to content

Instantly share code, notes, and snippets.

@davenicoll
Last active February 4, 2021 20:53
Show Gist options
  • Save davenicoll/da7fb2546bfdb39cde9c2623f6237328 to your computer and use it in GitHub Desktop.
Save davenicoll/da7fb2546bfdb39cde9c2623f6237328 to your computer and use it in GitHub Desktop.
Create a random password in bash
random_password()
{
LENGTH=32; if [[ -n "$1" ]]; then LENGTH=$1; fi
</dev/urandom tr -dc '0-9-a-z-A-Z@#()-=_+[]{},.' | head -c"$LENGTH"; echo ""
}
PASSWORD=$(random_password 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment