If you run a VPS, you know the drill. Something feels off, you open a terminal, SSH in, try to remember the right command, check the logs, restart a service. And if you're on your phone? Forget it.
What if you could just text your server and ask it what's going on — in plain English? That's exactly what we're building today with OpenClaw, a free, open-source AI agent that lives on your server and talks to you through Telegram.
What You'll Build
By the end of this guide, you'll have an AI agent on your server that you can message from Telegram to:
- Check if your website is up and healthy
- Monitor disk space, CPU, and memory usage
- Read and summarize nginx access logs
- Restart services like nginx or your Node.js app
- Edit source code and deploy changes — all from one message
- Diagnose performance issues with AI-powered analysis
The Architecture
[VPS 1: Website] <--- SSH ---> [VPS 2: OpenClaw + Telegram]
nginx AI Agent
Next.js app Controls VPS 1
VPS 1 runs your website (a Next.js app behind nginx). VPS 2 runs OpenClaw, which connects to Telegram and has SSH access to VPS 1.
Step 1: Create a Dedicated User
SSH into your second VPS. Create a dedicated user — don't run this as root:
adduser openclaw
usermod -aG sudo openclaw
loginctl enable-linger openclaw
su - openclaw
Step 2: Install OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bash
The installer starts onboarding automatically. Connect your LLM (OpenRouter + DeepSeek V3.2), then connect Telegram via BotFather bot token.
Step 3: Set Up the Background Service
source ~/.bashrc
mkdir -p /run/user/$(id -u)
echo 'export XDG_RUNTIME_DIR=/run/user/$(id -u)' >> ~/.bashrc
echo 'export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"' >> ~/.bashrc
source ~/.bashrc
openclaw gateway install --force
systemctl --user daemon-reload
systemctl --user start openclaw-gateway.service
systemctl --user enable openclaw-gateway.service
Verify: openclaw gateway status — should show "Runtime: running".
Step 4: SSH Access to Website Server
ssh-keygen -t ed25519
ssh-copy-id root@YOUR_WEBSITE_SERVER_IP
Step 5: Pair with Telegram
Send your bot a message, then approve the pairing code:
openclaw pairing approve telegram YOUR_CODE
Step 6: Give OpenClaw Context
Send one detailed message in Telegram with your server's IP, SSH user, file paths, service names, and deploy steps. OpenClaw has persistent memory — it remembers everything.
What It Can Do
- Health Check: "Is my site up?" → SSHes in, curls the site, reports status
- Disk Space: "How much disk space is left?" → Human-readable summary
- Log Analysis: "Show nginx access logs from last hour" → AI-summarized traffic patterns
- Service Restart: "Restart nginx" → Done. Confirmed.
- Code + Deploy: "Change the heading to 'Powered by AI'" → Edits code, rebuilds, restarts service
- AI Diagnosis: "My site feels slow" → Checks CPU, memory, disk, nginx, response time — full diagnosis
Why Not Just a Bash Script?
A script runs one command. OpenClaw thinks. It checks multiple metrics, synthesizes a diagnosis, remembers your server config, and gives human-readable answers instead of raw terminal output.
OpenClaw is free, open-source, and runs on any server. Connect it to Telegram, Discord, WhatsApp, or whatever you use.
Originally published at ayyaztech.com
Top comments (0)