Skip to content

Instantly share code, notes, and snippets.

@amithgc
Created August 10, 2021 09:29
Show Gist options
  • Save amithgc/0446f0632182e9d55ff5c0878eb96af6 to your computer and use it in GitHub Desktop.
Save amithgc/0446f0632182e9d55ff5c0878eb96af6 to your computer and use it in GitHub Desktop.
Telegram Message on SSH
#!/bin/bash
TOKEN="<BOT_TOKEN>"
ID="<GROUP_CHAT_ID>"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
if [ "$PAM_TYPE" != "open_session" ]
then
exit 0
else
curl -s -X POST $URL -d chat_id=$ID -d text="$(echo -e "Host: `hostname`\nUser: $PAM_USER\nHost: $PAM_RHOST")" > /dev/null 2>&1
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment