Hi guys today i am going to show how to enable email notification after logged into server via ssh
# nano ~/.bash_profile
insert the following lines:
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_EMAIL_ADDRESS
* Please rename "YOUR_EMAIL_ADDRESS" with your mail address
# yum install mailx
thats all
thats all