-
-
Save SafeAF/4313693b9f4792a9912f to your computer and use it in GitHub Desktop.
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