Passwortgenerator
Ein einfacher Passwortgenerator
#!/bin/bash # Generate a random password # # $1 number of characters; defaults to 20 # # $2 charset # 0 = special characters, numbers and letters (default) # 1 = numbers and letters # 2 = letters only # # # usage: pwgen.sh <LENGTH> <CHARS> # # examples: # # length = 20, special characters, numbers and letters # pwgen.sh # # length = 10, special characters, numbers and letters # pwgen.sh 10 # # length = 8, numbers and letters # pwgen.sh 8 1 # # length = 25, letters only # pwgen.sh 25 2 if [ "$1" = "" ]; then LENGTH=20; else LENGTH=$1 fi if [ "$2" = "" ]; then CHARS="[:graph:]" fi if [ "$2" = "1" ]; then CHARS="[:alnum:]" fi if [ "$2" = "2" ]; then CHARS="[:alpha:]" fi cat /dev/urandom | tr -dc $CHARS | head -c $LENGTH echo