tgsh
tgsh
A Telegram bot (template) to access the shell on YOUR server.
⚠️ DO NOT use it on cloud VMs -- violates ToS.
The bot supports:
- Short commands;
- Long-running commands;
- Communication with long-running processes via POSIX signals (only
INTandTSTPwith the same behavior in the template); - Checking working directory;
- Running Python scripts;
- Downloading files from the server;
- Uploading files to the server.
For each user, the bot creates two files:
PID_<chat_id>-- Process ID of the long-running process.LOG_<chat_id>.log-- Log file of the output of the long-running process. Contents of this file are sent line-by-line to the user as they appear. Users can also specify a custom log file for Python scripts.
Installation
Currently, the installation process is manual. Follow these steps:
- Clone the repository:
git clone https://github.com/Scurrra/tgsh.git - Install dependencies:
shards install - Configure the bot in
config.ymlin the root directory of the repository - Run the bot:
shards run -Dasync
Configuration
bot_token: YOUR_BOT_TOKEN_HERE
# Array of Telegram IDs
admins:
- YOUR_TELEGRAM_ID_HERE
# Number of milliseconds to wait before checking the status of the long-running process.
delay: 100
# Id of the last update processed; optional, as each update can be processed only once
offset: 0
# Timeout in seconds for long polling.
timeout: 20
# URL of the Telegram API.
# Override this if you're using your own bot server.
url: https://api.telegram.org
Usage
Bot has the following commands:
/start: Start the bot/help: Show help message/set_log_file: Create a log file for Python scripts/unset_log_file: Forget the name of a custom log file./delete_log_file: Delete the log file for Python scripts./pwd: Check working directory./bsh: Run a short command (completes before sending results to the user)./sh: Run a long-running command; output of the command will be sent to the user line-by-line./python: Run a Python script, all the arguments should be passed as usual; if custom log file is set, the bot will run command assuming that the script writes the output to the log file itself./get: Get a file from the server by its name./signal: Send a signal to the bot. Only signals can be processed while long-running commands are running. Currently supported signals are:INT(SIGINT, Ctrl+C): Interrupt the long-running command.TSTP(SIGTSTP, Ctrl+Z): Same asINT.
To upload a file to the server, just send it to the bot (media can be sent as a file too). Optionally, include a directory name in the caption to specify where the file should be saved. The directory will be created with mkdir -p, so existing directories won’t be overwritten, and nested directories are supported.
Development
Clone the repository using git clone https://github.com/Scurrra/tgsh.git or use it as a template for your own project.
Contributing
- Fork it (https://github.com/Scurrra/tgsh/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Scurrra -- creator and maintainer
tgsh
- 0
- 0
- 0
- 0
- 1
- 4 days ago
- November 7, 2025
MIT License
Mon, 02 Feb 2026 16:08:57 GMT