SSH Login Notification on Centos


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

දිරියක් වෙන්න අදහස් පෙළක් දාන්න

Post a Comment (0)
Previous Post Next Post