Skip to content

Instantly share code, notes, and snippets.

@fagci
Last active December 11, 2021 17:55
Show Gist options
  • Save fagci/996be37f5df97492f30703769021ccbd to your computer and use it in GitHub Desktop.
Save fagci/996be37f5df97492f30703769021ccbd to your computer and use it in GitHub Desktop.
Send notification to Telegram channel on SSH login
# ~/.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