Python app to launch sshd server from Telegram
Project description
SSH Telegram Manager
SSH Telegram Manager is a Telegram bot designed to launch your SSH daemon on demand. This tool allows you to keep your SSH port closed by default, enhancing security by only exposing it when you explicitly request it via Telegram.
Features
- On-demand SSH: Start your SSH server only when needed via a Telegram command.
- Automatic Shutdown: SSH server automatically closes after a configurable timeout.
- External IP Display: Easily retrieve your server's external IP address via Telegram.
- Secure by Default: Avoid permanent exposure of your SSH port to the internet.
Installation
-
Install the package:
pip install ssh_telegram_manager
-
Obtain a Telegram Bot Token: Follow a guide like this one ( https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token ) to get your bot token: How to get Telegram Bot API Token
-
Configure the bot:
- Create the configuration directory if it doesn't exist:
sudo mkdir -p /etc/ssh_telegram_manager/
- Copy the default configuration file to the system-wide configuration path:
sudo cp /path/to/your/cloned/repo/etc/ssh_telegram_manager/ssh_telegram_manager.default /etc/ssh_telegram_manager/ssh_telegram_manager
(Replace/path/to/your/cloned/repo/with the actual path where you cloned thessh_telegram_managerrepository). - Edit the copied configuration file (
/etc/ssh_telegram_manager/ssh_telegram_manager) and replaceYOUR_TELEGRAM_BOT_TOKENwith the token you obtained in step 2.
- Create the configuration directory if it doesn't exist:
-
Run the bot:
ssh_telegram_manager
For production environments, it's recommended to run this as a systemd service. A sample
ssh_telegram_manager.servicefile is available in theetc/directory of the repository. -
Enhance Security (Recommended): Once the
ssh_telegram_manageris working correctly, disable your SSH daemon from starting automatically at boot. This ensures your SSH port is not permanently exposed to the internet.sudo systemctl disable ssh
Configuration
The main configuration file is located at /etc/ssh_telegram_manager/ssh_telegram_manager.
It uses INI format and contains the following sections:
[Telegram]
Token = YOUR_TELEGRAM_BOT_TOKEN
[SSHD]
command_start = systemctl start sshd
command_stop = systemctl stop sshd
timeout = 60
-
[Telegram]Token: Your Telegram Bot API token. This is mandatory for the bot to connect to Telegram.
-
[SSHD]command_start: The shell command executed to start your SSH daemon. Default issystemctl start sshd. Adjust if your system uses a different command (e.g.,service ssh start).command_stop: The shell command executed to stop your SSH daemon. Default issystemctl stop sshd. Adjust if your system uses a different command.timeout: The number of seconds the SSH daemon will remain active after being started by the/ssh_startcommand. After this period,command_stopwill be executed. Default is60seconds.
Usage
Interact with your bot on Telegram using the following commands:
/ssh_start: Starts the SSH daemon on the server. It will automatically shut down after the configuredtimeoutperiod. The bot will send a confirmation message with the server's hostname and the command executed./ip: Displays the external IP address of the server where the bot is running. This is useful if your server's IP changes or if you need to quickly share it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ssh_telegram_manager-1.1.0.tar.gz.
File metadata
- Download URL: ssh_telegram_manager-1.1.0.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.13.13 Linux/7.0.8-gentoo
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b217a4481bf9210a1bcf5fbfee52cac7d9e5612cf3b1057a2382db4b9e69257
|
|
| MD5 |
6fbce493c990d3863113c84369b64234
|
|
| BLAKE2b-256 |
9f091adc4c7520f3e3c7accaa59713d78f6c61d4441472259861a3273c243205
|
File details
Details for the file ssh_telegram_manager-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ssh_telegram_manager-1.1.0-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.13.13 Linux/7.0.8-gentoo
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e096b3899995c5ad5a1d2cc6cf289bfa31420901b70ff7f7ffcd10d66ab87cfc
|
|
| MD5 |
ee5796b0f255dfc483bcfe0c91f6b297
|
|
| BLAKE2b-256 |
76764769dd6e5082a34eb520e263daf35c468b36c742c6b6c91236d2664b98b3
|