Curious to know when a user logs into your server successfully via SSH? Using Pushover notifications you can have something like this.
Fortunately, tying together PAM and Pushover is painless.
Log into Pushover and register an application. Spruce things up with a relevant icon and make note of the application’s API token and your user key.
Next, grab this small script and place it somewhere on the server. I put mine here, /etc/ssh/pam-pushover.sh. Edit the script and insert your API token and user key like so,
PUSHOVER_APPTOKEN="<YOUR_APP_TOKEN>"
PUSHOVER_USERKEY="<YOUR_USER_KEY>"
Make sure the script is executable
chmod +x /etc/ssh/pam-pushover.sh
Add the following line to /etc/pam.d/sshd
# Notify Pushover on successful login
session optional pam_exec.so seteuid /etc/ssh/pam-pushover.sh
Upon next successful login your Pushover client should be greeted with a nice notification. Also, since this is a PAM configuration, with minimal modification you could extend this to samba, sudo, etc.
Leave a Reply