#!/bin/bash

source $(dirname $0)/utils.sh

declare -a errList
nagexit(){ code=$1; shift; echo $@; exit $code;}
# It should have ssh closed to password
grep "PasswordAuthentication" /etc/ssh/sshd_config | grep -q "^PasswordAuthentication no" || errList+=("SSH config: password allowed")

# It should not be running fail2ban
pgrep fail2ban &>/dev/null && errList+=("Fail2ban running")

[[ 0 -eq ${#errList[@]} ]] && nagexit $STATE_OK "OK"

echo "Errors:"
for i in ${!errList[@]}; do
  echo "  * ${errList[$i]}"
done
exit $STATE_CRITICAL

