Put the following in /etc/profile:

The script /etc/profile is executed at every login (for bash shell users).

 

if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostname -f)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login" you@your.domain aFrom:youradd@email.com
fi

 


If you have issues delivering mail to a GMAIL inbox, make sure your domain is the first entry in /etc/hosts..

127.0.0.1

.