Get a Telegram Notification when someone logs in to your Linux Computer (Server, Laptop, Desktop).
Download this repository, all needed files are in the folder /src. Open a terminal and start with:
$ cd /etc
$ sudo nano profile
(Opens a terminal editor)- Copy the last line from src/profile in your editor. Close the editor with Ctrl+S & Ctrl+X.
- Copy the file src/notfier.py somewhere to your home directory. Fill in Telegram Bot Token and your chat id. Remember the path and run
$ sudo chmod +x notifier.py
$ sudo nano opt/login.sh
- Copy content from src/login.sh in the editor and fill in the remembered path. Close the editor with Ctrl+S & Ctrl+X and run
$ sudo chmod +x login.sh
.
- When you log in the /etc/profile script will be executed --> It is used to set system wide environmental variables on users shells.
- The line /opt/login.sh will be executed --> /opt is for third-party applications that don't rely on any dependencies outside the scope of packages.
- /opt/login.sh will then execute a python script on wherever path you want. You can also place it in /opt or your home directory.
- The python script (notifier.py) uses the package telebot to communicate with Telegram. -->
$ pip3 install pyTelegramBotAPI
- Try
$ sudo chmod +x path/to/file.sh or file.py
to make the scripts and python code executable
Eventually I will built an installer in the future...