Pages

Wednesday, November 29, 2023

Generate Strong Password Using Bash Script

Generate Strong Password Using Bash Script

  • upper alphabeth
  • lower alphabeth
  • number
  • symbol


then combine and shuffle mix using Bash


pass1="$(head /dev/urandom | tr -dc 'A-Z' | head -c3)" # upper alphabeth
pass2="$(head /dev/urandom | tr -dc 'a-z' | head -c3)" # lower alphabeth
pass3="$(head /dev/urandom | tr -dc '0-9' | head -c3)" # number
pass4="$(head /dev/urandom | tr -dc '!@#$%^&*()' | head -c3)" # symbol
password=$pass1$pass2$pass3$pass4
mixed_password=$(echo "$password" | fold -w1 | shuf | tr -d '\n')
echo $mixed_password

ShareThis