So I am trying to get email notifications setup on about 100 servers and I am using an if script that works perfectly, however I have a tool that ssh's into each machine ever 5 min to gather statistics. I am trying to adapt the script to ignore any ssh attempts from 1 IP. I have racked my brain and I think I have looked through every possible question on the subject. Any help would be amazing thank guys!!!
Currently the script sends an email no matter who ssh's in.
#!/bin/sh
# Change these two lines:
sender="[email protected]"
recepient="[email protected]"
if [ "$PAM_RUSER" != "192.168.1.10" ]; then
goto done
next
if [ "$PAM_TYPE" != "close_session" ]; then
host="`hostname`"
subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
# Message to send, e.g. the current environment variables.
message="`env`"
echo "$message" | mail "$sender" -s "$subject" "$recepient"
fi
fi