Security doesn't exist, no system is safe

You are not logged in.

#1 2016-05-08 11:30:13

modInfo
Administrator
From: Neustadt
Registered: 2012-01-04
Posts: 476
Website

Pushover notifications for SSH logins

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,

#!/bin/sh

PUSHOVER_API_URL="https://api.pushover.net/1/messages.json"

PUSHOVER_APPTOKEN="<YOUR_APP_TOKEN>"
PUSHOVER_USERKEY="<YOUR_USER_KEY>"

if [ "$PAM_TYPE" != "close_session" ]; then
    MESSAGE="User '$PAM_USER' logged into '`hostname`' from IP address '$PAM_RHOST'"
    curl -s -F "user=$PUSHOVER_USERKEY" -F "token=$PUSHOVER_APPTOKEN" -F "message=$MESSAGE" $PUSHOVER_API_URL
fi

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.


sysadmin

LinuxFirefox 46.0

Offline

Board footer

Powered by FluxBB