Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch convert passwords to htaccess/htpasswd

Status
Not open for further replies.

dadpups

Technical User
Mar 13, 2003
7
US
i have about 1000 user name password combos that i need to convert to apache passwords. i prefer not to do it one by one. is there a script that will take a flat file like this

dog:cat
big:little
smart:dumb

and convert in one fell swoop to

dog:mnaofjapdae (or whatever the conversion is...)

many thanks,

dadpups
 
Do you have perl available?
Do you have the app "htpassword" available, and is it the version that can take a password from the command-line?

If so, the following perl script will do it for you:
Code:
#! /usr/bin/perl

use strict;

my $passwordfile = 'passwords.txt';

my $htpasswordfile = '.htpassword';
my $arguments = '-cb';

open (IN, &quot;< $passwordfile&quot;);

while (<IN>)
{
        my ($name, $password) = split (/:/);

        `htpasswd $arguments $htpasswordfile $name $password`;

        $arguments = '-b';
}

close (FH);

Change $passworfile to the name of your input username/password list. Want the best answers? Ask the best questions: TANSTAAFL!
 
Many thanks!

I have perl. I don't think I have the app &quot;htpassword.&quot;

Do you know where I can get it?

Dadpups
 
I am at a host called phpwebhosting. Apache server.

OS - Linux dev.mod.cx 2.4.16-010stab016.2.777

 
I believe I can telnet, but I haven't been successful yet. I will return when I get PuTTY to work - God willing! Thanks.
 
I don't think I have the app &quot;htpassword.&quot;

Just to be clear, the actual command (or 'app') is 'htpasswd', without the 'or'. This is what you want to check for.

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top