BASH script to email when someone logins to my server?

vpsnewb

New Member
I remember seeing this somewhere and want to add it to what I am working on. It would send an email anytime someone would login to your VPS via SSH. It looked really simple but I didn't bookmark it.

Anyone know how to accomplish this?
 

D. Strout

Resident IPv6 Proponent
Quick Google turns up this: How do I set up an email alert when a ssh login is successful? (AskUbuntu, though I imagine it applies to other OSes)
 

acd

New Member
A more general solution is to use pam_script.so in the appropriate /etc/pam.d file adding the line


session required pam_script.so onsessionopen=/etc/yourscript.sh
This will execute the script file on login. You can use this hook to grab logins to any service that uses pam for authentication which includes most non-vhost services on linux.
 
Top