Skip to content

Instantly share code, notes, and snippets.

@hankpillow
Created April 1, 2011 19:06
Show Gist options
  • Save hankpillow/898671 to your computer and use it in GitHub Desktop.
Save hankpillow/898671 to your computer and use it in GitHub Desktop.
this script creates htaccess files in the same root as when you called this script
#!/bin/bash
user=$1;
if [ "$user" = "" ]
then
echo -n "user name:"
read user
fi
pwd | awk '{root = $1}; END {print "AuthName \"Secure Area\"\nAuthType Basic\nAuthUserFile " root "/.htpasswd\nrequire valid-user" }' > .htaccess
htpasswd -c .htpasswd $user
chmod 644 .htpasswd
@hankpillow
Copy link
Author

chmor +x path-to-this-gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment