filter for private IP added

This commit is contained in:
m8in
2026-03-20 20:47:26 +01:00
parent 363ed88731
commit 320cc2009b

View File

@@ -73,10 +73,21 @@ function setup() {
return 0 return 0
} }
if [ "$PAM_TYPE" != "close_session" ] && ! setup && [ "${PAM_USER}" != "" ] && [ "${PAM_USER}" == "root" ]; then if [ "$PAM_TYPE" != "close_session" ] && ! setup && [ "${PAM_USER}" != "" ]; then
# Log root logins only
[ "${PAM_USER}" != "root" ] \
&& exit 0
# Skip logins from private IPs
echo "${PAM_RHOST}" | grep -Eq "^192\.168\..*$" \
&& exit 0
_MESSAGE="[$(date --rfc-3339=seconds)] - Login from IP: '${PAM_RHOST}' as user 'root@$(hostname)'" _MESSAGE="[$(date --rfc-3339=seconds)] - Login from IP: '${PAM_RHOST}' as user 'root@$(hostname)'"
log "${_MESSAGE}" log "${_MESSAGE}"
sendEMail "${_MESSAGE}" sendEMail "${_MESSAGE}"
sendSlackMessage "${_MESSAGE}" sendSlackMessage "${_MESSAGE}"
fi fi
exit 0