Send email on SSH login using PAM

Goal

When a user logs in using SSH an email should be sent.

Intro

There are different ways to send an email when someone logs into a machine using SSH. One way could be to parse the auth log file periodically, but this is error prone and rather complex. An easier way is to call a script, that is hooked into PAM, the central authentication service on Linux systems.
Continue reading