Send SSH root login alert

From Wiki
Jump to: navigation, search
if [ "$SSH_TTY" ] ; then
        DATE=`date`
        IP=`echo $SSH_CLIENT
        USER=`id -un`
        echo -e "User: $USER\nIP: $IP\nDate: $DATE" | mail -s ""Alert: Remote Access Granted to `id -un`" email@host.net"
fi