Send Email Alert on SSH Access

How to send an email alert on SSH access? Here we go

#nano ~/.bash_profile

and add this at the bottom of the page

IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")

echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' your@domain.com
Please rate this article to help us improve our Knowledge Base.

0 0




Hello , talk to a hosting specialist today and discover which options will work best for you.

+255 734 666 100