[GLLUG] Re: Apache Authentication

wattersm wattersm at wattersm.net
Sun Jul 13 14:46:33 EDT 2003


Thomas Alan Hearn writes: 

> Hello fellow GLLUGers,
> I have yet another question concerning apache.  This time my problem is as 
> follows.  I am transferring a website that used to be on a windows apache 
> server, and the login for the site was .htaccess and http auth type login. 
> My problem is that the .htpasswd file was stored with the passwords in 
> plain text on the windows machine.  If I remember correctly, i believe 
> linux requires that .htpasswd files be store encrypted?  My problem is 
> that there are over 300 users on the site and to manually change all those 
> passwords would be horrible.  Anyone have any suggestions, and if not, 
> know how to get about encrypting the file?  
> 
> Thanks in advance,
> Cheers,
> Tom
> _______________________________________________
> linux-user mailing list
> linux-user at egr.msu.edu
> http://www.egr.msu.edu/mailman/listinfo/linux-user
 

Python can do it. 

#!/usr/bin/python 

import os
import string 

f = open('htpasswd_win') 

password_list = f.readlines() 

f.close 

#This is in case htpasswd_linux does not exist
os.system("touch htpasswd_linux") 

for x in password_list:
      x.strip()
      user = string.split(x, ":")
      os.system("htpasswd -b htpasswd_linux %s %s" %(user[0], user[1]) ) 

print "List converted successfully.\n" 

Pretty much anything on unix can be scripted, so learning perl or python or 
any other scripting language will make things much easier on you. 




More information about the linux-user mailing list