Last active
December 30, 2015 23:39
-
-
Save benclark/7901943 to your computer and use it in GitHub Desktop.
Test for basic auth on all Apache virtual host sites
This file contains 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 | |
vhosts=/etc/apache2/sites-enabled/* | |
for f in $vhosts | |
do | |
servername=`grep ServerName $f | sed 's/\s*ServerName\s*//g' - | head -n1` | |
for s in $servername | |
do | |
url="http://$s https://$s" | |
for protocol in $url | |
do | |
result=`curl -s -I $protocol | grep "401 Authorization Required"` | |
if [ -z "$result" ] | |
then | |
echo "WARNING: $protocol does not have basic auth!" | |
fi | |
done | |
done | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment