Friday, 14 August 2015

htpasswd for multiple users using bash script

Step 1# Add users   in /tmp/users.txt

vim /tmp/users.txt
mansoor
user1
user2
:wq


Step 2# Create & Run script
vim htpasswd_change.sh
#!/bin/bash
for user in `cat /tmp/users.txt`
do
pass=`tr -dc A-Za-z0-9 < /dev/urandom | head -c 6 | xargs`
htpasswd -bm /var/www/html/webserver/htpasswd $user $pass
echo "$user " " : " " $pass"
done




No comments:

Post a Comment