Skip to content

A simple script to check whenever a user log in or log out from your system.

License

Notifications You must be signed in to change notification settings

matteounitn/telegram-ssh-login-notification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

telegram-ssh-login-notification

security level

A simple script to check whenever a user log in or log out from your system.

Based on this script but fixed, using only PAM.

Requirements

  1. A server (tested on ubuntu)
  2. A telegram account
  3. Create a telegram bot from the BotFather and start a chat with it.

The url of your newly created bot will look like http://t.me/your_bots_name

Copy the HTTP API: token generated by the BotFather.

  1. Use @getmyid_bot bot to get your user ID. Should be in the form
Your user ID: XXXXXXXXX 
Current chat ID: XXXXXXXXX
  1. Edit the script as below

What to do

  1. Check your /etc/ssh/sshd_config: UsePAM yes it's mandatory.
  2. git clone https://github.com/Matteounitn/telegram-ssh-login-notification.git
  3. cd telegram-ssh-login-notification and here nano script.sh

HERE you HAVE TO SET:

USERID="<YOUR-ID>"
KEY="<API-KEY-OF-YOUR-BOT>" 
  1. sudo nano /etc/pam.d/sshd and add the following snippet at the end of the file
session optional pam_exec.so /path/to/your/cloned/repo/telegram-ssh-login-notification/script.sh
  1. sudo chmod a+x /path/to/your/cloned/repo/telegram-ssh-login-notification/script.sh
  2. Not mandatory, but reccomended: sudo service ssh restart or sudo systemctl restart sshd or sudo systemctl restart ssh

Thanks to

This guy, for the basic script

Alberto Xamin for sending me the link and helping me with the code.

About

A simple script to check whenever a user log in or log out from your system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages