Email or SMS alert / notification on SSH login using PHP script

Get Email or SMS notification on SSH login with PHP script using these instructions

Create a new file called sshrc in /etc/ssh/
Paste these commands:
TEXT="$(date): ssh login to ${USER}@$(hostname -f)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
/usr/bin/php /var/www/ "$TEXT"

Then in your PHP script
< ? php 
$arg1 = $argv[1];
mail("","[SMS] SSH Login", "SSH Login notification: $arg1");
? >

Now you will receive an email every time someone logs in to your SSH server. If you also want to receive SMS message create a filter in your gmail account using [SMS] in the subject line and forward it to your phone as

❮ Back to blog