Initial commit

This commit is contained in:
Valentin DEVILLE
2017-05-21 21:31:46 +02:00
commit 799811d34e
4 changed files with 53 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
## Alert via telegram when user logon via SSH
Work on all popular linux system (Debian <3, Ubuntu, Arch Linux etc..)
![Example](msg.png)
### Requirement
- curl
Yes only this !
### Install
1) Clone this repo or copy alert.sh for example in /root/:
```cd /root/ && git clone https://github.com/MyTheValentinus/ssh-login-alert-telegram```
2) Edit two configuration variables by editing alert.sh:
```editor alert.sh```
3) Add this script when user connect, edit bashrc, profile or openssh-server option etc..
```sh deploy.sh```
_(Don't forget to change the path of script if you use deploy.sh)_
4) Test it !
5) Start this project and tweet me (@MyTheValentinus) ! Thanks ;) <3
Executable
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Your USERID or Channel ID to display alert and key, we recommend you create new bot with @BotFather on Telegram
USERID=""
KEY=""
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE="$(date "+%d %b %Y %H:%M")"
if [ -n "$SSH_CLIENT" ]; then
CLIENT_IP=$(echo $SSH_CLIENT | awk '{print $1}')
SRV_HOSTNAME=$(hostname -f)
SRV_IP=$(hostname -I | awk '{print $1}')
IPINFO="https://ipinfo.io/$CLIENT_IP"
TEXT="Connection from *$CLIENT_IP* as $USER on *$SRV_HOSTNAME* (*$SRV_IP*)
Date: $DATE
More informations: [$IPINFO]($IPINFO)"
curl -s -d "chat_id=$USERID&text=$TEXT&disable_web_page_preview=true&parse_mode=markdown" $URL > /dev/null
fi
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "# Log connection" >> /etc/profile
echo "sh /root/ssh-login-alert-telegram/alert.sh" >> /etc/profile
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB