Created
October 12, 2013 19:13
-
-
Save tommybutler/6953743 to your computer and use it in GitHub Desktop.
See this page for details and usage instructions: http://www.atrixnet.com/send-an-email-when-someone-logs-in/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice