Wednesday, March 19, 2008

apache htpasswd password generator

I had to generate random password for a whole bunch of apache httpd users, so I’ve written a script that generates a 8 digit random password:

#!/bin/sh
if [ $# -ne 2 ]
then
echo “passwdgen.sh passwordfile username”
exit
fi

PASS=`date +%N md5sum - cut -c1-8`
echo $2:$PASS
if [ ! -f $1 ]
then
touch $1
fi
/$APACHE_HTTPD_HOME/bin/htpasswd -bm $1 $2 $PASS

No comments: