dont supsend if outgoing connections present

This commit is contained in:
cronekorkn 2022-09-21 22:11:09 +02:00
parent 1ea39b8117
commit c8a916d5ac
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw

View file

@ -34,12 +34,21 @@ do
fi
done
# CHECK FOR ACTIVE LOGINS
# CHECK FOR INCOMING SSH CONNECTIONS
LOGINS=$(netstat -tnpa | grep 'ESTABLISHED.*sshd' | tr -s ' ' | cut -d' ' -f5,7-8 | paste -d',' -s | sed 's/,/, /')
LOGINS=$(netstat -np | grep 'ESTABLISHED.*sshd' | tr -s ' ' | cut -d' ' -f5,7,8)
if ! [[ -z "$LOGINS" ]]
then
echo "ABORT: users logged in: $LOGINS"
echo "ABORT: incoming ssh connections: $LOGINS"
exit 75
fi
# CHECK FOR OUTGOING SSH CONNECTIONS
LOGINS=$(netstat -np | grep 'ESTABLISHED.*ssh[^d]' | tr -s ' ' | cut -d' ' -f5,7,8)
if ! [[ -z "$LOGINS" ]]
then
echo "ABORT: outgoing ssh connections: $LOGINS"
exit 75
fi