[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache: adding massive amount of users for .htaccess from text file



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 <michael@noname.franken.de>
use your idle CPU cycles - See http://www.distributed.net for details.
Visit our mud Geas at geas.franken.de Port 3333



Reply to: