Get an e-mail every time someone logs in via SSH
If you want an e-mail every time someone logs in via SSH to your machine follow these easy steps.
1. Edit /etc/pam.d/sshd. Add the two following lines anywhere.
#Send email alert on each SSH login
session optional pam_exec.so /usr/bin/email_who.sh
2. Create and edit /usr/bin/email_who.sh. Add the following lines.
#!/bin/bash tail /var/log/auth.log | mail -s "SSH Login: `hostname -f`" -t someone@server.org
3. Make the e-mail script executable.
sudo chmod 755 /usr/bin/email_who.sh
Original post can be found here: http://www.webhostingtalk.com/showthread.php?t=924848.