Skip to main content

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

  1. Install the package:

    pip install ssh_telegram_manager
    
  2. 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

  3. 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 the ssh_telegram_manager repository).
    • Edit the copied configuration file (/etc/ssh_telegram_manager/ssh_telegram_manager) and replace YOUR_TELEGRAM_BOT_TOKEN with the token you obtained in step 2.
  4. Run the bot:

    ssh_telegram_manager
    

    For production environments, it's recommended to run this as a systemd service. A sample ssh_telegram_manager.service file is available in the etc/ directory of the repository.

  5. Enhance Security (Recommended): Once the ssh_telegram_manager is 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 is systemctl 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 is systemctl 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_start command. After this period, command_stop will be executed. Default is 60 seconds.

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 configured timeout period. 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.

Metadata

Release files for ssh-telegram-manager 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssh-telegram-manager 1.1.0
File Size Uploaded
ssh_telegram_manager-1.1.0.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssh-telegram-manager 1.1.0
File Interpreter ABI Platform
ssh_telegram_manager-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.4 kB

Release files / ssh_telegram_manager-1.1.0.tar.gz

Download URL ssh_telegram_manager-1.1.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7b217a4481bf9210a1bcf5fbfee52cac7d9e5612cf3b1057a2382db4b9e69257
BLAKE2b-256 checksum
How to use checksums
9f091adc4c7520f3e3c7accaa59713d78f6c61d4441472259861a3273c243205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.13 Linux/7.0.8-gentoo

Release files / ssh_telegram_manager-1.1.0-py3-none-any.whl

Download URL ssh_telegram_manager-1.1.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e096b3899995c5ad5a1d2cc6cf289bfa31420901b70ff7f7ffcd10d66ab87cfc
BLAKE2b-256 checksum
How to use checksums
76764769dd6e5082a34eb520e263daf35c468b36c742c6b6c91236d2664b98b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.13 Linux/7.0.8-gentoo

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.6.0

2 release files

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page