Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
See this page for details and usage instructions: http://www.atrixnet.com/send-an-email-when-someone-logs-in/
#!/bin/bash
RECIPIENT="your.email@address.here";
PREFIX="LOGIN ALERT!";
REMOTEIP=$(/bin/echo $SSH_CLIENT | /usr/bin/awk '{ print $1 }');
TIME=$(/bin/date +'%r, %D');
HOST=$(/bin/hostname -f);
if [[ "$REMOTEIP" == "" ]]; then
REMOTEIP='localhost';
fi
/bin/cat <<LOGGEDIN | /usr/bin/mail -s "$PREFIX $USER@$HOST $TIME" $RECIPIENT
Remote user $USER just logged in to $HOST at $TIME from $REMOTEIP
LOGGEDIN
exit $?
@eznode

This comment has been minimized.

Copy link

eznode commented Nov 13, 2018

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.