-
-
Save rahmatov/f682f3d4ea0ca511a0c87531a6022b8e to your computer and use it in GitHub Desktop.
Revisions
-
matriphe revised this gist
Jul 28, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,8 @@ 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 IP=$(echo $SSH_CLIENT | awk '{print $1}') PORT=$(echo $SSH_CLIENT | awk '{print $3}') HOSTNAME=$(hostname -f) IPADDR=$(hostname -I | awk '{print $1}') curl http://ipinfo.io/$IP -s -o $TMPFILE -
matriphe revised this gist
Jul 28, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,8 @@ TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt' if [ -n "$SSH_CLIENT" ]; then IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -f) IPADDR=$(hostname -I | awk '{print $1}') curl http://ipinfo.io/$IP -s -o $TMPFILE CITY=$(cat $TMPFILE | jq '.city' | sed 's/"//g') REGION=$(cat $TMPFILE | jq '.region' | sed 's/"//g') -
matriphe revised this gist
Jul 28, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt' if [ -n "$SSH_CLIENT" ]; then IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -I | awk -F ' ' '{ print $1 }') IPADDR=$(hostname -i) curl http://ipinfo.io/$IP -s -o $TMPFILE CITY=$(cat $TMPFILE | jq '.city' | sed 's/"//g') -
matriphe revised this gist
Jul 28, 2015 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,11 @@ # 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 IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -f) @@ -17,6 +18,6 @@ if [ -n "$SSH_CLIENT" ]; then COUNTRY=$(cat $TMPFILE | jq '.country' | sed 's/"//g') ORG=$(cat $TMPFILE | jq '.org' | sed 's/"//g') TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME ($IPADDR) from $IP - $ORG - $CITY, $REGION, $COUNTRY on port $PORT" curl -s --max-time $TIMEOUT -d "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null rm $TMPFILE fi -
matriphe revised this gist
Jul 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,6 @@ if [ -n "$SSH_CLIENT" ]; then COUNTRY=$(cat $TMPFILE | jq '.country' | sed 's/"//g') ORG=$(cat $TMPFILE | jq '.org' | sed 's/"//g') TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME ($IPADDR) from $IP - $ORG - $CITY, $REGION, $COUNTRY on port $PORT" curl --connect-timeout=30 -d -s "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null rm $TMPFILE fi -
matriphe revised this gist
Jul 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,6 @@ if [ -n "$SSH_CLIENT" ]; then COUNTRY=$(cat $TMPFILE | jq '.country' | sed 's/"//g') ORG=$(cat $TMPFILE | jq '.org' | sed 's/"//g') TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME ($IPADDR) from $IP - $ORG - $CITY, $REGION, $COUNTRY on port $PORT" curl -s -d --connect-timeout=30 "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null rm $TMPFILE fi -
matriphe revised this gist
Jul 2, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ # 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>" URL="https://api.telegram.org/bot$KEY/sendMessage" -
matriphe revised this gist
Jul 2, 2015 . 1 changed file with 19 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,23 @@ # save it on /etc/profile/profile.d/ # use jq to parse JSON from ipinfo.io # get jq from here http://xmodulo.com/how-to-parse-json-string-via-command-line-on-linux.html # http://stedolan.github.io/jq/ USERID="<target_user_id>" KEY="<bot_private_key>" URL="https://api.telegram.org/bot$KEY/sendMessage" TMPFILE='/tmp/ipinfo.txt' if [ -n "$SSH_CLIENT" ]; then DATE_EXEC="$(date "+%d %b %Y %H:%M")" IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -f) IPADDR=$(hostname -i) curl http://ipinfo.io/$IP -s -o $TMPFILE CITY=$(cat $TMPFILE | jq '.city' | sed 's/"//g') REGION=$(cat $TMPFILE | jq '.region' | sed 's/"//g') COUNTRY=$(cat $TMPFILE | jq '.country' | sed 's/"//g') ORG=$(cat $TMPFILE | jq '.org' | sed 's/"//g') TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME ($IPADDR) from $IP - $ORG - $CITY, $REGION, $COUNTRY on port $PORT" curl -s -d "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null rm $TMPFILE fi -
matriphe revised this gist
Jun 27, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ if [ -n "$SSH_CLIENT" ]; then IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -f) IPADDR=$(hostname -i) TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME ($IPADDR) from $IP on port $PORT" curl -s -d "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null fi -
matriphe revised this gist
Jun 27, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # save it on /etc/profile/profile.d/ USERID="<user_or_group_id>" KEY="<telegram_bot_api_key>" URL="https://api.telegram.org/bot$KEY/sendMessage" -
matriphe created this gist
Jun 27, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ USERID="<user_or_group_id>" KEY="<telegram_bot_api_key>" URL="https://api.telegram.org/bot$KEY/sendMessage" if [ -n "$SSH_CLIENT" ]; then DATE_EXEC="$(date "+%d %b %Y %H:%M")" IP=$(echo $SSH_CLIENT|awk '{print $1}') PORT=$(echo $SSH_CLIENT|awk '{print $3}') HOSTNAME=$(hostname -f) TEXT="$DATE_EXEC: ${USER} logged in to $HOSTNAME from $IP on port $PORT" curl -s -d "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null fi