Skip to content

Instantly share code, notes, and snippets.

View iqbwl's full-sized avatar
💭
I may be slow to respond.

iqbwl iqbwl

💭
I may be slow to respond.
View GitHub Profile
@matriphe
matriphe / ssh-telegram.sh
Last active May 7, 2023 15:00
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then