hedockerssh-tgbot
Manage hedockerssh — Docker containers exposed as SSH connections — through a Telegram bot.
Built directly on top of the hedockerssh.services API: every Docker operation the bot performs goes through the official service layer of DockerSSH.
Features
- Container lifecycle — start / stop / restart / delete with inline buttons and confirmation for destructive actions
- Guided container creation (
/new) — pick a local Docker image, platform, port and password step by step; everything optional with sensible defaults - Password handling — auto-generated or custom passwords, sent in a separate message that self-deletes after 60 seconds; the message containing a custom password is deleted from the chat immediately
- Platform environment management — list, install (build) and remove the platform runtimes DockerSSH needs
- Pagination — every list shows 5 items per page with prev/next buttons
- Access control — strict user-ID whitelist; nobody else can even talk to the bot
- Robust service bridge — synchronous Docker calls run in worker threads with stdout capture (no password leaks to logs), timeouts and normalized error codes mapped to human-readable messages
Requirements
- Linux or macOS with a working Docker daemon (incl.
buildx) — the bot runs on the Docker host - uv
- A Telegram bot token from @BotFather
- Your Telegram user ID from @userinfobot
Install
Install the bot as a uv tool (recommended):
uv tool install hedockerssh-tgbot
Then start it:
dockerssh-tgbot
Run dockerssh-tgbot again after editing the configuration file; configuration is read at startup.
Configuration
Configuration lives in a JSON file next to the DockerSSH data:
- Linux:
/var/lib/dockerssh/tgbot.json - macOS:
~/Library/Application Support/dockerssh/tgbot.json
The file is created with an empty template on first start — fill it in and start again:
{
"TELEGRAM_BOT_TOKEN": "123456:ABC-...",
"DOCKERSSH_ADMIN_IDS": "123456789,987654321",
"HOST": ""
}
| Key | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Yes | Bot token issued by @BotFather |
DOCKERSSH_ADMIN_IDS |
Yes | Telegram user IDs allowed to use the bot. Comma-separated string or JSON array |
HOST |
No | Domain or IP shown in SSH instructions. Auto-detected when empty |
Real environment variables (TELEGRAM_BOT_TOKEN, DOCKERSSH_ADMIN_IDS, HOST) override the values in the file.
Migration: if a legacy
.envfile exists in the working directory on first start, its values are imported intotgbot.jsonautomatically.
Commands
Commands are registered with Telegram, so they show up in the menu button next to the input field.
| Command | Description |
|---|---|
/new |
Create an SSH container via a wizard (image, platform, port, password) |
/list |
List containers — tap one to open its detail view |
/help, /start |
Show help |
/env_list |
Show installed and supported platform environments |
/env_install |
Install a platform environment (runs a build, may take minutes) |
/env_remove |
Remove a platform environment |
/cancel |
Cancel the current dialog |
Creating a container
/newlists local Docker images (or pass one directly:/new ubuntu:24.04)- Choose a platform — auto-detect or one of the installed runtimes
- Choose a port — auto-assign or a specific 1-65535 port
- Choose a password — auto-generate or type your own (6-64 chars)
- Confirm — the bot replies with the
sshconnection line and sends the password in a self-deleting message
Managing containers
/list shows containers 5 per page. Tapping one opens a detail view with status, image, platform and the actions ▶️ Start / ⏸ Stop / ♻️ Restart / 🔑 Reset password / 🗑 Delete (with confirmation). Resetting a password offers the same auto-generate / manual input flow as /new.
Security
- Only whitelisted user IDs may interact with the bot; all others are dropped
- Password-bearing messages are deleted: custom passwords immediately after reading, generated passwords 60 seconds after sending
- Service-layer stdout (which prints passwords in plain CLI mode) is captured and never reaches the chat or logs
- The bot inherits your Docker permissions — treat the bot token like a shell account
Development
Run from source:
git clone <this-repo> && cd hedockerssh-tgbot
uv sync
uv run dockerssh-tgbot
Project layout:
src/hedockerssh_tgbot/
├── __init__.py # main(): config, wiring, command registration, polling
├── config.py # tgbot.json loading, .env migration, validation
├── auth.py # global whitelist gate (ApplicationHandlerStop)
├── bridge.py # sync→async bridge: threads, stdout capture, timeouts
├── ui.py # error mapping, pagination, secrets, HTML helpers
└── handlers/
├── containers.py # /list, /new wizard, detail view, password flows
└── envs.py # platform environment commands
Disclaimer
SSH passwords travel through Telegram servers. Assess the risk for your threat model before using this in production.
Metadata
Release files for hedockerssh-tgbot 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hedockerssh_tgbot-1.0.0.tar.gz | 12.7 kB | Without provenance | Details for hedockerssh_tgbot-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hedockerssh_tgbot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for hedockerssh_tgbot-1.0.0-py3-none-any.whl |
Total release size: 29.8 kB
Release files / hedockerssh_tgbot-1.0.0.tar.gz
| Download URL | hedockerssh_tgbot-1.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df8722c9906d93ff93156e8dc147e1ac694a51372439c854d827d6b62ba17fa4
|
|
BLAKE2b-256 checksum How to use checksums |
0e83c8b33777cca6b99715e70834b0a2b2d90f416b1806682b63a6f0df9f777e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / hedockerssh_tgbot-1.0.0-py3-none-any.whl
| Download URL | hedockerssh_tgbot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b02c7d67b4d5fcc77c46b5f04aa28b564441666135a178811011e62c1d468abd
|
|
BLAKE2b-256 checksum How to use checksums |
7b89bd3b777b8d6af2489972ca35e06c1fb5c575958c19a6902365691392dc15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for hedockerssh-tgbot 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.