Centos 7 – Email Alert SSH login + Mail from

Last updated on August 5th, 2019 at 07:12 am

Open nano ~/.bash_profile and add the folowing:

IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
NOW=$(date +"%e %b %Y, %a %r") 
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' -r "SSS Login<[email protected]_domain.com>" [email protected]_domain.com


!!!!!!!!Your_domain ————- must be valid domain.


Leave a comment

Your email address will not be published. Required fields are marked *