Multipass documentation and code has been updated again! (December 28, 2005) Finally!
Rate this script!
Why multipass was written
This little script was written (in PERL) after creating sites with hundreds or thousands of registered users that needed password access to protected directories (Specifically, CSCS, ISCA and ICD).
What it does
Multipass takes a list of usernames and passwords, one set per line, separated by colons and stored in a plain text file, encrypts the passwords and stores the resulting pairs in an .htaccess file.
Installation
First, download multipass. Unzip it and open it in your text editor.
The following need to be edited: (Click on the hyperlinked lines to see editing comments)
#!/usr/bin/perl
use CGI;
$q = new CGI;
print $q->header();
use CGI::Carp qw(fatalsToBrowser);
%in = $q->Vars;
umask (011);
# Change this next line to the path to your words.txt
$unencrypted_pwords='/path/to/words.txt';
# Change this next line to the path to your .htpasswd file
$htpasswd_FILE = '/path/to/.htpasswd';
# You shouldn't have to modify anything below this unless you know what you're doing.
$salt1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./';
open(PREAD,"<$unencrypted_pwords") or die ('Could not open unencrypted password file');
while () {
chomp;
($user,$pass) = split(/\:/,$_);
$words{$user}=$pass;
}
close (PREAD);
open(HTPASS,">>$htpasswd_FILE") or die ('Could not find specified file');
$number = 0;
foreach $key (keys %words) {
$salt = substr($salt1,rand(length($salt1)),1);
$salt .= substr($salt1,rand(length($salt1)),1);
$pass=$words{$key};
$encryptedpass = crypt ($pass,$salt);
print HTPASS "$key:$encryptedpass\n";
$words{$key}=$encryptedpass;
++$number;
}
close(HTPASS);
print "Done! $number usernames and passwords added to $htpasswd_FILE.<BR>Multipass was written by <A HREF=\"http://www.internalysis.com\">InternAlysis.com</A>.<BR>";
foreach $key (keys %words) {
print "$key : $words{$key}<BR>\n";
}
Copyright
This script is being distributed as donation/postcardware. If you like it, if it saves you time and money, please feel free to send either $20 (much appreciated) or a postcard to the address in the comments section of multipass.cgi (Don't need spam bots grabbing the address from here)
Want more?
Do you find these scripts interesting? Do they make your life easier, save you money or improve your website is substantial ways?
If you have an idea for a CGI application for development, but don't have the resources or time to develop it, we'd be happy to help you with your custom CGI needs. You'll find our rates are very reasonable, as well as in Canadian dollars. Please contact us for more information.
If you found this script saved you time and money, you could probably also use Membermanager or Recommend.