Skip to content

Instantly share code, notes, and snippets.

@benclark
Last active December 30, 2015 23:39
Show Gist options
  • Save benclark/7901943 to your computer and use it in GitHub Desktop.
Save benclark/7901943 to your computer and use it in GitHub Desktop.
Test for basic auth on all Apache virtual host sites
#!/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