ServerManagerBot is a Telegram bot designed for managing Hetzner servers. With this bot, administrators can effortlessly control server operations such as listing servers, powering them on or off, rebooting, and resetting passwords—all through Telegram.
- Features
- Requirements
- Getting Started
- Updating the Bot
- Managing the Bot with Docker
- Bot Usage
- Error Handling
- ⭐ What's Next?
- Contact
- Manage Hetzner servers directly via Telegram.
- Power servers on/off, reboot, and delete them.
- Support for Docker on multiple platforms (Linux/amd64, Linux/arm64).
- Robust error handling for both Hetzner API and bot operations.
- Python 3.11
- Hetzner API Token
- Telegram Bot Token
- Docker and Docker Compose
Ensure your server is up to date by running:
sudo apt update && sudo apt upgrade -y
If Docker isn't already installed, set it up with:
curl -fsSL https://get.docker.com | sh
Clone the ServerManagerBot repository and navigate to the project directory:
git clone https://github.com/erfjab/ServerManagerBot.git
cd ServerManagerBot
Copy the example configuration file to create a new configuration file:
cp data/.info.json.example data/.info.json
Open the data/.info.json
file and insert your Telegram Bot Token and Hetzner API keys:
nano data/.info.json
Replace the placeholders with your information:
{
"TELEGRAM_BOT_TOKEN": "your-telegram-bot-token",
"TELEGRAM_BOT_ADMINS": {
"admin_chat_id": "hetzner_api_token"
}
}
- TELEGRAM_BOT_TOKEN: Get this from Telegram BotFather.
- TELEGRAM_BOT_ADMINS: Map your Telegram chat IDs to their Hetzner API tokens. Your
chat_id
is your Telegram user ID.
Tip
Click here for instructions on generating a Hetzner API token.
Ensure your docker-compose.yml
is set up like this:
services:
ServerManagerBot:
image: erfjab/ServerManagerBot:latest
restart: always
volumes:
- ./data/:/code/data/
-
Pull the latest Docker image:
docker compose pull
-
Start the bot:
docker compose up -d
-
Verify the bot is running:
docker compose ps
This command lists the running containers.
To update the bot to the latest version:
-
Pull the latest Docker image:
docker compose pull
-
Restart the bot:
docker compose up -d
docker compose restart
docker compose down
To check real-time logs of the bot:
docker compose logs -f
- Start a chat with the bot on Telegram.
- Use the
/start
command to view a list of your Hetzner servers. - Execute actions such as powering on/off, rebooting, and resetting passwords.
The bot includes comprehensive error handling for:
- Hetzner API issues.
- Connection problems.
- Invalid user inputs.
All errors are logged and can be monitored using Docker logs.
- Show Servers List
- Display Full Server Info
- Power On Servers
- Power Off Servers
- Perform Reset (Power Cycle)
- Reset Root Password
- Delete Servers
- Rebuild (all images)
- Reboot Servers
- Provide Exclusive Access for Each Admin
- Create New Servers
- Set Server Limits for Admins
- Implement Dedicated Proxies for Access
- Change Server IP
- Manage Server IP Types (Add/Delete)
- Telegram Channel: @ErfJabs
Feel free to ⭐ the project to show your support!