Ejbca Scripts
Scipts for generating lots of users
Made by kinneh and MrsTidy 2007
Tested to generate 20.000 Users, be aware of diskusage (We used about 2GB)
Script to generate a file of users to create with next script
#!/bin/sh
NUMBER_OF_USERS=30000
i=0
START_AT=99
i=`expr $i + $START_AT`
NUMBER_OF_USERS=`expr $NUMBER_OF_USERS + $START_AT`
while [ $i -lt $NUMBER_OF_USERS ] ; do
i=`expr $i + 1`
pnr=`echo $i | perl -ane 'printf("1990%08d", $_)'`
echo "BatchTest$i:foo123:CN=Batch Test $i,SN=$pnr,DC=TEST,C=SE:Labb_ANV_CA_l3:1:P12:Labb_ANV:Labb_ANV_END_ENTITY"
done
The script to add those users in the file
#!/bin/sh
if [ -z $EJBCA_HOME ] ;then
echo "EJBCA_HOME not set"
exit
fi
cd $EJBCA_HOME
if [ 1 -o "x$1" != "x" ] ; then
if [ -r $1 ] ; then
file=$1;
else
echo "cant read file: $1"
exit
fi
else
echo "argument 1 should be a file with:"
echo "username:password:dn:caname:type:certificate profile:endentity profile"
exit
fi
while read row ; do
# "username:password:dn:caname:type:certificate profile:endentity profile"
ejbcaUsername=`echo $row | cut -f1 -d\:`
ejbcaPassword=`echo $row | cut -f2 -d\:`
ejbcaDn=`echo $row | cut -f3 -d\:`
ejbcaCaname=`echo $row | cut -f4 -d\:`
ejbcaType=`echo $row | cut -f5 -d\:`
ejbcaToken=`echo $row | cut -f6 -d\:`
ejbcaCerProf=`echo $row | cut -f7 -d\:`
ejbcaEndentProf=`echo $row | cut -f8 -d\:`
# adduser
echo "./bin/ejbca.sh ra adduser $ejbcaUsername $ejbcaPassword \"$ejbcaDn\" null $ejbcaCaname null $ejbcaType $ejbcaToken $ejbcaCerProf $ejb
caEndentProf"
./bin/ejbca.sh ra adduser $ejbcaUsername $ejbcaPassword "$ejbcaDn" null $ejbcaCaname null $ejbcaType $ejbcaToken $ejbcaCerProf $ejbcaEndent
Prof
# set passwd
echo "./bin/ejbca.sh ra setclearpwd $ejbcaUsername $ejbcaPassword "
./bin/ejbca.sh ra setclearpwd $ejbcaUsername $ejbcaPassword
done
# finally batch
echo "./bin/ejbca.sh batch"
./bin/ejbca.sh batch
Sample inputfile
BatchTest1:foo123:CN=Batch Test 1,SN=9900001001,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest2:foo123:CN=Batch Test 2,SN=9900001002,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest3:foo123:CN=Batch Test 3,SN=9900001003,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest4:foo123:CN=Batch Test 4,SN=9900001004,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest5:foo123:CN=Batch Test 5,SN=9900001005,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest6:foo123:CN=Batch Test 6,SN=9900001006,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest7:foo123:CN=Batch Test 7,SN=9900001007,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
BatchTest8:foo123:CN=Batch Test 8,SN=9900001008,DC=TEST,C=SE:Utv_ANV_CA:1:P12:Utv_ANV_END_ENTITY_Profile:Utv_ANV_Profile
page_revision: 0, last_edited: 1205139418|%e %b %Y, %H:%M %Z (%O ago)