Bash script to Generate a Strong Password

I use separate, very long, randomly generated passwords for everything.

This short script does the job.

#!/bin/sh
# genpasswd [number of characters]
 
if [ -z "$1" ]; then
  echo "usage: genpasswd [number of characters]"
  exit 1
fi
 
tr -dc A-Za-z0-9_ < /dev/urandom | head -c $1 | xargs
Be Sociable, Share!

3 thoughts on “Bash script to Generate a Strong Password

  1. I also remove some characters that could be confused with other ones:

    cat /dev/urandom|tr -dc [:alnum:]|tr -d 1IlioO0|head -c$1

Comments are closed.