On Fri Feb 20, 2004 at 12:0533PM +0100, Erik D�rnbach wrote:
> Hello list,
> 
> just a quickie, I need to add a massive load of users for apache
> authentication, I have the usernames and associated passwords in
> a plain text file, one line per user like:
> 
> <username1>:<plainpassword>
> <username2>:<plainpassword>
> ...
> 
> Database auth would be an overshot, these users will likely never
> change.
> 
> Is there an easy way to automate password encryption for use with
> apache, thinking about maybe someone has a ready-to-use shell
> script or perl snippet.

untested, quick and dirty

#!/usr/bin/perl

while (<>) {
   ($username, $password)=split /:/, $_, 2;
   system("/usr/bin/htpasswd", "-b", "/path/to/htaccess", $username, $password);
}

It expects the list of usernames and passwords to be sperated by : and
to be piped to stdin. Problems might occur, when a username contains :
(in the password, there shouldn't be a problem)


-- 
Michael Bergbauer <[EMAIL PROTECTED]>
use your idle CPU cycles - See http://www.distributed.net for details.
Visit our mud Geas at geas.franken.de Port 3333


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to