Created
August 10, 2021 09:29
-
-
Save amithgc/0446f0632182e9d55ff5c0878eb96af6 to your computer and use it in GitHub Desktop.
Telegram Message on SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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