From c842c40c89580def646fe6776c1f81cab593bce1 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sat, 3 Sep 2022 14:41:24 +0200 Subject: [PATCH] misc/ssh_tg_notify: Lookup & inform user which logged in as well --- roles/misc/ssh_tg_notify/templates/notify.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/misc/ssh_tg_notify/templates/notify.sh b/roles/misc/ssh_tg_notify/templates/notify.sh index f4c3e48..d9e47d5 100644 --- a/roles/misc/ssh_tg_notify/templates/notify.sh +++ b/roles/misc/ssh_tg_notify/templates/notify.sh @@ -31,5 +31,10 @@ if [[ "$PAM_SERVICE" == "sshd" && "$PAM_TYPE" == "open_session" && "$PAM_USER" ! TEXT="Successful login from [$IP](https://stat.ripe.net/app/$IP) for ${PAM_USER} @ ${HOSTNAME} ($(date "+%Y-%m-%d %H:%M"))" # send to root ROOT_USER_ID="$(getUserId root)" - sendMessage "$ROOT_USER_ID" "$TEXT" + sendMessage "$ROOT_USER_ID" "$TEXT (This message was sent to you because you are the admin.)" + # send to user if id is known + USER_ID="$(getUserId "$PAM_USER")" + if [[ -n "$USER_ID" ]]; then + sendMessage "$USER_ID" "$TEXT" + fi fi