--- Dave <[EMAIL PROTECTED]> wrote:
> I have a csv plain text file that I would like to import as a htaccess > file, the password is plaint text so it would need to encrypt the > password. Anyone know of a script that does this? The .htaccess file does not contain usernames and encrypted passwords for Apache's mod_auth. The .htaccess file has the Apache directives (commands) which are used to tell the web server how to behave, including requiring a valid username and password be supplied before pages in a given directory and subdirectory are sent to the web browser. That said, you need to have some sort of file which does contain these usernames and passwords for the mod_auth module to authenticate against. Sometimes this file is called .htpasswd and I think this may be the source of your confusion. The mod_auth system can accept either crypt (old Unix style hashes) or md5 (newer and more secure) encrypted passwords. A sample .htpasswd file could contain entries like: joe:83ARHAhyBoBNA sue:g8NJJIUea/6PQ zebra:JU/naZI9oX2q2 apache101:$1$Z1e0Dpp1$eANI2bMwijXeJcU0Y9seM/ The username is on the left, followed by a comma and a hash from crypt or md5. The first three examples use crypt and could be cracked in a relatively short period of time if someone could access this file. The md5 hashes are harder to crack. Your first step involves reading in the CSV file and processing each line to create the .htpasswd file in the above format. You haven't said much about the specific format of the CSV file so I can't be more specific. As you generate each line, you will need to create the crypt or md5 hash. A language like PHP has functions for crypt() and md5() hash generation. I assume that Perl does as well. I haven't spotted one suitable for a Bash shell script. Incidentally, if you were trying to set Linux system passwords from a text file, it would be relatively easy to do so with the chpasswd command. Unfortunately, your situation is a little different. James _____ James D. Keeline http://www.Keeline.com http://www.Keeline.com/articles http://Stratemeyer.org http://www.Keeline.com/TSCollection http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc. Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks. -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie
