A simple and secure bot for executing shell commands via Telegram.
This bot provides remote shell access. Use with caution and implement proper security measures:
- Create a dedicated Linux user with restricted permissions
- Use strong passwords and keep credentials secure
- Enable only trusted Telegram users
- Regularly audit command logs
- Message @BotFather on Telegram
- Send
/newbotcommand - Choose a name (e.g., "My Server Shell")
- Choose a username (must end in 'bot')
- Save the API token you receive
- Message @userinfobot on Telegram
- Save the ID number it sends you
-
Copy all files to your server:
scp -r ./* user@your-server:/tmp/telegramShell/ -
SSH into your server:
ssh user@your-server
-
Run the deployment script:
cd /tmp/telegramShell sudo chmod +x deploy.sh sudo ./deploy.sh -
Create and edit the .env file:
sudo -u telegram_bot nano /home/telegram_bot/telegramShell/.env
Add these lines:
TELEGRAM_TOKEN=your_bot_token ALLOWED_USERS=your_telegram_user_id BOT_PASSWORD=your_secure_password -
Restart the service:
sudo systemctl restart telegram-shell-bot
-
Check service status:
sudo systemctl status telegram-shell-bot
-
View logs if needed:
sudo journalctl -u telegram-shell-bot -f
- Start chat with bot:
/start - Authenticate:
/auth your_password - Type commands directly:
ls -la- Or with slash prefix:
/ls -la
- Or with slash prefix:
- Get help:
/help
- Open multiple chat windows with the bot
- Dedicate one window for log monitoring:
tail -f /path/to/logfile - Use other windows for running commands
- Press Ctrl+C in Telegram to stop viewing output
- List files:
ls -la - Monitor log:
tail -f /var/log/syslog - System info:
htop - Check disk space:
df -h - Process list:
ps aux
- Check service status:
sudo systemctl status telegram-shell-bot
- View logs:
sudo journalctl -u telegram-shell-bot -f
- Check permissions:
ls -la /home/telegram_bot/telegramShell/ sudo -l -U telegram_bot