Last active
December 11, 2021 17:55
-
-
Save fagci/996be37f5df97492f30703769021ccbd to your computer and use it in GitHub Desktop.
Send notification to Telegram channel on SSH login
This file contains 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
# ~/.ssh/rc | |
chat='<chat_id>' | |
token='<token>' | |
msg="*SSH $(uname -n)* | |
\`\`\` | |
User: ${USER} | |
Remote IP: ${SSH_CONNECTION%% *} | |
\`\`\` | |
" | |
curl -sd "chat_id=${chat}&text=${msg}&parse_mode=markdown" \ | |
"https://api.telegram.org/bot${token}/sendMessage" >/dev/null & | |
# vi: ft=bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment