How to get an email every time someone logs in via SSH into your server

  bash, linux
sudo nano /etc/profile

Add this section at the bottom

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" your_email_address_here@gmail.com
fi