Created
August 29, 2014 09:01
-
-
Save deepfriedmind/b8df8dc5517b0afc2728 to your computer and use it in GitHub Desktop.
HTPGen – Quickly generate .htpasswd / .htaccess files for basic Apache authentication. To be able to run `htpgen.sh` from anywhere, place the file somewhere that's included in your `PATH`, e.g. `/usr/local/bin` or `/usr/bin`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "Enter username: " -r ht_username | |
read -p "Enter password: " -sr ht_password | |
echo -en "\n" | |
read -p "Enter full path to where .htpasswd will be placed on the web server: " -r ht_path | |
htpasswd -nb $ht_username $ht_password > .htpasswd | |
echo "AuthType Basic | |
AuthName \"Log in\" | |
AuthUserFile $ht_path | |
Require valid-user" > .htaccess | |
echo " | |
.htaccess / .htpasswd files created in $PWD | |
Username: $ht_username | |
Path: $ht_path | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment