Skip to content

Instantly share code, notes, and snippets.

@aauren
Last active August 29, 2015 14:07
Show Gist options
  • Save aauren/b4e868ad05bf79ceaf45 to your computer and use it in GitHub Desktop.
Save aauren/b4e868ad05bf79ceaf45 to your computer and use it in GitHub Desktop.
Salt Command To Check For Open HTTPS Ports + Find Domain Name If Apache
# Command to find all servers and show whether they have an SSL port open or not
salt '*' cmd.run "if netstat -an 2>/dev/null |grep -qE '.*(443|8443)+[ \t]+.*LISTEN[ \t]*$'; then echo '+++SSL Port Found+++'; apachectl -S 2>&1 |grep -E '(:443|port 443)'; else echo '---SSL Port Not Found---'; fi"
# Same command as above, except only display servers with an open SSL port
salt '*' cmd.run "if netstat -an 2>/dev/null |grep -qE '.*(443|8443)+[ \t]+.*LISTEN[ \t]*$'; then echo '+++SSL Port Found+++'; apachectl -S 2>&1 |grep -E '(:443|port 443)'; else echo '---SSL Port Not Found---'; fi" |tac | sed '/---SSL Port Not Found---/,+1 d' |tac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment