Hacker News new | ask | show | jobs
by lazyant 3807 days ago
If you want to send email on login, add in /etc/profile :

echo "`whoami` logged in at `date` from `echo $SSH_CLIENT`" | mail -s "`hostname` login" youremail@example.com

Note that people can still ssh execute remotely etc.

2 comments

You'll definitely want to add a '&' at the end of that line so that you don't delay user logins if the network is down or mail barfs.
right, actually I do have a delay in a server with no mail where it fails :-)
pam_exec seems to be a more robust solution to login notifications than /etc/profile http://blog.stalkr.net/2010/11/login-notifications-pamexec-s...