background-hooknotifierbackground-hooknotifier
Last update: Jul 04, 20261 minutes read

Get notified when someone logs into your server over SSH

low-code

Get a push notification the moment someone logs into your server over SSH. A few lines in one file plus your Hook.Notifier URL. No agent, no service. Free.

To get notified when someone logs into your server over SSH, add a call to your Hook.Notifier URL in the server's login hook. Every session then pings your phone with who logged in and from where.

Add it to the login hook

On most Linux servers, add one line to /etc/pam.d/sshd.

# /etc/pam.d/sshd  (add at the end)
session optional pam_exec.so /usr/local/bin/notify-ssh.sh

Then create the script it runs:

# /usr/local/bin/notify-ssh.sh
#!/bin/bash
if [ "$PAM_TYPE" = "open_session" ]; then
  curl -s "https://hooknotifier.com/{IDENTIFIER}/{KEY}?object=SSH%20login&body=${PAM_USER}%20from%20${PAM_RHOST}&priority=high"
fi

Make it executable with chmod +x /usr/local/bin/notify-ssh.sh. The next SSH login lands on your phone.

The priority=high matters here. A security alert should not wait for the morning: high and critical priority cut through your quiet hours, so a 3am login still buzzes. Use critical on machines where any unexpected session is an incident.

hook notifier notification

First get your URL

Your Hook.Notifier URL is https://hooknotifier.com/{IDENTIFIER}/{KEY}. Create a free account to get yours, then drop it into the script.

Why it matters

An SSH login you did not expect is the earliest sign something is wrong. Getting a ping on every session, yours or not, means you notice the odd one instantly instead of finding it in a log later.

New to this? Start with how to send yourself a native push notification.