From 4d48c5dc3406b57c05ddeedc60d98d03053c009d Mon Sep 17 00:00:00 2001
From: Philipp Heckel <pheckel@datto.com>
Date: Mon, 8 Nov 2021 20:15:13 -0500
Subject: [PATCH] Examples

---
 .../notify-desktop.sh}                                    | 0
 examples/ssh-login-alert/ntfy-ssh-login.sh                | 7 +++++++
 examples/ssh-login-alert/pam_sshd                         | 8 ++++++++
 .../example-ssh.html}                                     | 0
 4 files changed, 15 insertions(+)
 rename examples/{example_desktop_notifications.sh => linux-desktop-notifications/notify-desktop.sh} (100%)
 create mode 100644 examples/ssh-login-alert/ntfy-ssh-login.sh
 create mode 100644 examples/ssh-login-alert/pam_sshd
 rename examples/{example_eventsource_sse.html => web-example-eventsource/example-ssh.html} (100%)

diff --git a/examples/example_desktop_notifications.sh b/examples/linux-desktop-notifications/notify-desktop.sh
similarity index 100%
rename from examples/example_desktop_notifications.sh
rename to examples/linux-desktop-notifications/notify-desktop.sh
diff --git a/examples/ssh-login-alert/ntfy-ssh-login.sh b/examples/ssh-login-alert/ntfy-ssh-login.sh
new file mode 100644
index 0000000..4c92c44
--- /dev/null
+++ b/examples/ssh-login-alert/ntfy-ssh-login.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# This is a PAM script hook that shows how to notify you when
+# somebody logs into your server. Place at /usr/local/bin/ntfy-ssh-login.sh (with chmod +x!).
+
+if [ "${PAM_TYPE}" = "open_session" ]; then
+  echo -en "\u26A0\uFE0F SSH login to $(hostname): ${PAM_USER} from ${PAM_RHOST}" | curl -T- ntfy.sh/alerts
+fi
diff --git a/examples/ssh-login-alert/pam_sshd b/examples/ssh-login-alert/pam_sshd
new file mode 100644
index 0000000..fe1eec6
--- /dev/null
+++ b/examples/ssh-login-alert/pam_sshd
@@ -0,0 +1,8 @@
+# PAM config file snippet
+#
+# Put this snippet AT THE END of the file /etc/pam.d/sshd
+# See https://geekthis.net/post/run-scripts-after-ssh-authentication/ for details.
+
+# (lots of stuff here ...)
+
+session optional pam_exec.so /usr/local/bin/ntfy-ssh-login.sh
diff --git a/examples/example_eventsource_sse.html b/examples/web-example-eventsource/example-ssh.html
similarity index 100%
rename from examples/example_eventsource_sse.html
rename to examples/web-example-eventsource/example-ssh.html
-- 
GitLab