Skip to content

Instantly share code, notes, and snippets.

@rdalverny
Last active January 22, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdalverny/392b662988f78619789c3910b4d86753 to your computer and use it in GitHub Desktop.
Save rdalverny/392b662988f78619789c3910b4d86753 to your computer and use it in GitHub Desktop.
#!/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