Telegram bot that runs Linux shell commands
Project description
pebbles_bot
Table of content
Introduction
Pebbles is a bot which allows users to run shell commands on their Linux servers from Telegram.
It is designed to be self-hosted. To get it up and running clone repository on the server,
ask BotFather to create a bot,
save its API hash to ./pebbles_api
, and just run it!
What It Can Do Now
At this stage Pebbles is not very sophisticated, it can:
- Run commands locally.
- Establish a SSH connection to another host and run commands there.
What It Will Do In The Future
- Support more built-in commands to do various tasks.
- Support public key authentication for SSH connections.
- Send information from the server to Telegram (upon completion of a script, for example).
Is it secure to run a public bot with direct access to a server?
The bot's channel itself is encrypted and secure by default.
To verify this, run /setprivacy
on @BotFather
, then check if privacy settings are enabled.
However, the bot can still be found by its handle and access to the server could be compromised.
That is why Pebbles has a built-in whitelisting mechanism to only allow certain users to run
commands on it.
Example of pebbles_whitelist
0123456789
3141592653
0112358132
...
There is no limit on how much user IDs can be allowed, but the list cannot be empty. User ID
can be obtained from a public bot @userinfobot
, by calling /start
command on it.
So yeah, I'd say it is pretty secure :)
Deployment
- Clone the repository, navigate to it and install with pip
git clone https://github.com/Lab-Brat/pebbles_bot.git
cd pebbles_bot
python -m pip install .
-
Ask BotFather to create a bot, then save it's API key
-
Create a configuration file and paste your API key and authorized user IDs to it
---
pebbles:
api_key: '....................'
whitelist:
- '0123456789'
- '3141592653'
- Run Pebbles
pebot
Command Guide
/start
-> start interacting with Pebbles./help
-> print all available commands./mode
-> choose Pebbles modelocal
: run commands on the server it's deployedremote
: run commands on the remote server. To use this option a connection must be first established by/login
.
/login
-> establish a SSH connection to a remote host. User will be prompted for:- IP address or hostname.
If port is not specified (8.8.8.8:22) then port 22 will be used. - username
- password
If~/.ssh/config
has connection information (key and/or user), connection will still be established if a wrond password is entered. - confirmation
selectYes
to establish a connection,No
to cancel.
- IP address or hostname.
/logout
-> to terminate the SSH connection/run
-> run a shell command, where it runs depends on/mode
. After command call user will be prompted to enter a command, stdout or stderr will be returned
Project details
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
Hashes for pebbles_bot-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d85201524d5bbf3fd5ac7e108fe3340e7a1c212070c8e66642bf5006ff3f79e |
|
MD5 | 1b8fe395a6d4087e51cb0c117d39c828 |
|
BLAKE2b-256 | 16e65a53c4522cddffca09e34eebb2e7822726d415fce15754008db0fe7d429d |