Advertisement
Capoeirista

Telegram SSH 2

Oct 17th, 2021
1,637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.07 KB | None | 0 0
  1. #!/bin/bash
  2. # Telegram notification
  3. # Send msg when your server load to high
  4. token="BOT ID" # put your token here
  5. chat_id="CHAT ID" # your chat_id for sending notification
  6. sendmsg="https://api.telegram.org/bot$token/sendMessage?parse_mode=markdown" # url for sending msg
  7. sendfile="https://api.telegram.org/bot$token/sendDocument?parse_mode=markdown" # url for sending files
  8. date="$(date "+%d/%m/%Y %H:%M:%S")"
  9. caption_file=/tmp/ssh_caption_file.txt
  10. msg=/tmp/ssh_msg_info.txt
  11. curl http://ip-api.com/json/$PAM_RHOST -s -o $caption_file
  12. country=$(cat $caption_file | jq '.country' | sed 's/"//g')
  13. city=$(cat $caption_file | jq '.city' | sed 's/"//g')
  14. org=$(cat $caption_file | jq '.as' | sed 's/"//g')
  15. echo -e "*$PAM_USER* вошёл на *$HOSTNAME*\nДата: $date \nIP: $PAM_RHOST\nСтрана: *$country*\nГород: *$city*\nПровайдер: *$org*\n-------------------------------------------------" > $msg
  16. #curl -d text=$message -d chat_id=$chat_id $sendmsg
  17. curl $sendmsg -d chat_id=$chat_id -d text="$(<$msg)"
  18. rm /tmp/ssh_caption_file.txt
  19. rm /tmp/ssh_msg_info.txt
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement