Created
May 2, 2012 15:17
-
-
Save liconti/2577386 to your computer and use it in GitHub Desktop.
htpasswd usernames generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
num=${1:-10} | |
prefix=${2:-provRC_} | |
passwords=(`apg -n $num -m 8 -x8 -M sNC -E \/\*\(\)\/\&\%\$\£\"\!\,\?\;.JKWXYO -c cl_seed`) | |
for ((i=0;i<$num;i+=1)) | |
do | |
users[$i]=$prefix`printf "%03d" $i` | |
htpass[$i]=`htpasswd -nb ${users[$i]} ${passwords[$i]}` | |
cleanpass[$i]="${users[$i]} ${passwords[$i]}" | |
done | |
echo "usage: $0 number_of_user username_prefix" | |
echo "clean passwords" | |
for ((i=0;i<$num;i+=1));do echo ${cleanpass[$i]};done | |
echo | |
echo "htpasswd passwords" | |
for ((i=0;i<$num;i+=1));do echo ${htpass[$i]};done | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usersfile=$1 | |
passwords=(`apg -n 100 -m 8 -x8 -M sNC -E \/\*\(\)\/\&\%\$\£\"\!\,\?\;.JKWXYO -c cl_seed`) | |
#echo $passwords | |
unset users | |
unset htpass | |
unset cleanpass | |
i=0 | |
echo "scanning=$usersfile" | |
while read line | |
do | |
if [ -n "$line" ] | |
then | |
users[$i]=$line | |
#echo -e "$i - generatin htpasswd for user ${users[$i]}i" | |
#echo -e " htpasswd -nb ${users[$i]} ${passwords[$i]}" | |
htpass[$i]=`htpasswd -nb ${users[$i]} ${passwords[$i]}` | |
cleanpass[$i]="${users[$i]} ${passwords[$i]}" | |
let "i+=1" | |
fi | |
done < $usersfile | |
num=$i | |
echo "clean passwords" | |
for ((i=0;i<$num;i+=1));do echo ${cleanpass[$i]};done | |
echo | |
echo "htpasswd passwords" | |
for ((i=0;i<$num;i+=1));do echo ${htpass[$i]};done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment