Activity Stream
48,167 MEMBERS
61066 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 2 of 2
  1.     
    #1
    Member
    JackWell's Avatar

    Question How to generate an .htpasswd file without having Apache tools installed ?

    i would like to protect some of my folders on server but i wonder how can i generate .htpasswd file without apache tools installed on my linux server ?
    JackWell Reviewed by JackWell on . How to generate an .htpasswd file without having Apache tools installed ? i would like to protect some of my folders on server but i wonder how can i generate .htpasswd file without apache tools installed on my linux server ? Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Super Moderator
    GarryField's Avatar
    In Linux (and other Posix): given users John, Mary, Jane and Jim and passwords V3Ry, SEcRe7, V3RySEcRe7 and SEcRe7PwD, in order to generate a password file named .htpasswd, you would issue:

    printf "John:$(openssl passwd -crypt V3Ry)\n" >> .htpasswd # this example uses crypt encryption
    printf "Mary:$(openssl passwd -apr1 SEcRe7)\n" >> .htpasswd # this example uses apr1 (Apache MD5) encryption
    printf "Jane:$(openssl passwd -1 V3RySEcRe7)\n" >> .htpasswd # this example uses MD5 encryption
    (PASSWORD="SEcRe7PwD";SALT="$(openssl rand -base64 3)";SHA1=$(printf "$PASSWORD$SALT" | openssl dgst -binary -sha1 | \
    sed 's#$#'"$SALT"'#' | base64);printf "Jim:{SSHA}$SHA1\n" >> .htpasswd) # this example uses SSHA encryption
    • Or, you may use the following crypt.pl Perl script. Simply save it as e.g. crypt.pl and chmod 700 crypt.pl in order to be able to execute it.

    #!/usr/bin/perl
    use strict;

    chomp(my $filename=$ARGV[0]);
    chomp(my $username=$ARGV[1]);
    chomp(my $password=$ARGV[2]);

    if (!$filename || !$username || !$password) {
    print "USAGE: ./crypt.pl filename username password\n\n";
    } else {
    open my $fh, ">>", $filename or die $!;
    print $fh $username . ":" . crypt($password, $username) . "\n";
    close $fh or die $!;
    }
    Follow Board Rules & Thread Rules.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Installed WP is not showing !
    By shufol in forum Wordpress
    Replies: 7
    Last Post: 12th Nov 2012, 03:18 PM
  2. How Many Browsers Are Installed In Your PC?
    By lig}{tning in forum Polling Plaza
    Replies: 172
    Last Post: 11th Jan 2012, 06:49 AM
  3. Apache is not responding, with ruTorrent installed!
    By kundurocks in forum Technical Help Desk Support
    Replies: 1
    Last Post: 26th Mar 2011, 08:56 AM
  4. Set up PHPUploader. But RL is already installed. Help
    By fileserve-links in forum Technical Help Desk Support
    Replies: 13
    Last Post: 7th Oct 2010, 03:21 AM
  5. How To Keep Those Applications Installed?
    By mani in forum Technical Help Desk Support
    Replies: 6
    Last Post: 2nd Sep 2010, 09:38 PM

Tags for this Thread

BE SOCIAL