0

I got a script running on server , that generating a big file of user and password in format

   username ="johnuser"  password="johnpass"
   username ="adamuser"  password="adampass"

so on about 500 in list

This file is keep updating every 10 minute , with the list of users added or removed, I want to use this username and password to protect apache folder using htpasswd , is it possible to do that by any bash script that i can put in cron and can run to update my user list using htpasswd automatically .

Jahid
  • 21,542
  • 10
  • 90
  • 108
  • Fast idea: You could hash the name/passwort with the needed hashfunction for `.htpasswd` and then save the output file as `.htpasswd`, meaning you create your `.htpasswd` file with your phpscript – bish Jun 03 '15 at 08:30

1 Answers1

-2

You should use PHP instead of Apache : HTTP authentication with PHP

Sony
  • 1,773
  • 3
  • 23
  • 39
  • I found this script for this type of purpose but not sure how to implement #!/bin/sh FILE=$1 FS=":" while read line do # store field 1 NAME=$(echo $line|cut -d$FS -f1) # store field 2 PASSWORD=$(echo $line|cut -d$FS -f2) /usr/local/apache/bin/htpasswd -b .htpasswd $NAME $PASSWORD done < $FILE – user2901827 Jun 03 '15 at 08:36