Skip to content

Instantly share code, notes, and snippets.

View Kreumadragon's full-sized avatar

rhtgn Kreumadragon

View GitHub Profile
@Kreumadragon
Kreumadragon / notify-telegram.sh
Last active January 28, 2017 20:15
Own login notification via telegram bot api. (needs jq, apt install jq)
#Place this file under /etc/profile.d/ to get notifyed whenever someone goes through a login procedure in ssh
USERID="<the chatID where you want to get notificated>"#use api.telegram.org/bot$KEY/getUpdate to find out the ID
KEY="<your bot api-key here"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
#TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt' Only for additional IPLookup
if [ -n "$SSH_CLIENT" ]; then
IP=$(echo $SSH_CLIENT | awk '{print $1}')
PORT=$(echo $SSH_CLIENT | awk '{print $3}')