Skip to content

Instantly share code, notes, and snippets.

@grenade
Created December 16, 2021 06:29
Show Gist options
  • Save grenade/ef84d91f31847520a8257ee660117a8f to your computer and use it in GitHub Desktop.
Save grenade/ef84d91f31847520a8257ee660117a8f to your computer and use it in GitHub Desktop.
generate pragmatic passwords that are also secure

add to ~/.bashrc to have a password generator that:

  • removes problematic characters
  • always starts and ends with an english alphabet character
  • is of configurable length
pwg() {
  case ${1} in
    ''|*[!0-9]*) password_length=12 ;;
    *) password_length=${1} ;;
  esac
  pwgen -1 --symbols --ambiguous --remove-chars '\`%"><$'"'" ${password_length} 100 | egrep -i '^[a-z].*[a-z]$' | shuf | head -n 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment