Last active
January 22, 2018 16:36
-
-
Save rdalverny/392b662988f78619789c3910b4d86753 to your computer and use it in GitHub Desktop.
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 | |
# Wrapper for automated audits, | |
# using https://github.com/arthepsy/ssh-audit | |
# | |
set -euo pipefail | |
SSHAUDIT="ssh-audit.py" | |
OPTIONS="--batch --no-colors" | |
CMD="${SSHAUDIT} ${OPTIONS} $*" | |
OUTPUT=$(./${CMD}) | |
WARN=$(echo "${OUTPUT}" |grep -c "\[warn\]") | |
FAIL=$(echo "${OUTPUT}" |grep -c "\[fail\]") | |
REC=$(echo "${OUTPUT}" |grep -c "(rec)") | |
echo "$OUTPUT" | |
echo | |
echo "Summary:" | |
echo " * ${FAIL} errors" | |
echo " * ${WARN} warnings" | |
echo " * ${REC} recommandations" | |
echo "Command: ${CMD}" | |
if [[ "${WARN}" != "0" && "${FAIL}" != "0" ]]; then | |
echo "Result: FAIL" | |
echo "Status: 2" | |
exit 2 | |
fi | |
echo "Result: OK" | |
echo "Status: 0" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment