Skip to content

Instantly share code, notes, and snippets.

View Ernillew's full-sized avatar

Ergil Osin Ernillew

View GitHub Profile
@zamber
zamber / ssh-telegram.sh
Last active November 1, 2019 07:05 — forked from matriphe/ssh-telegram.sh
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use sed to parse JSON from ipinfo.io
# you can get your user_id by writing to @get_id_bot
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" ] && [ -z "$TMUX" ]; then