{"slug": "how-to-run-claude-code-on-a-vps-with-telegram-mobile-access", "title": "How to Run Claude Code on a VPS with Telegram Mobile Access", "summary": "Anthropic's Claude Code CLI tool can be run 24/7 on a virtual private server and controlled remotely from a mobile phone via Telegram. The setup requires provisioning an Ubuntu VPS, installing Node.js and the Claude Code package, configuring SSH key authentication and a firewall, and wiring in a Telegram bot using the Channels plugin for persistent terminal access through Tmux. This configuration offloads compute from a local machine and enables developers to check on long-running tasks, send instructions, or review output from anywhere without keeping a laptop open.", "body_md": "# How to Run Claude Code on a VPS with Telegram Mobile Access\n\nRun Claude Code 24/7 on a VPS and control it from your phone via Telegram. Step-by-step SSH, Tmux, and Channels plugin setup guide.\n\n## Why Running Claude Code on a VPS Makes Sense\n\nRunning Claude Code on a remote server changes how you work with it. Instead of keeping your laptop open, tethered to a project directory, you offload the compute to a VPS that runs around the clock. Add a Telegram bot on top and you can check in on long-running tasks, send new instructions, or review output from your phone — anywhere.\n\nThis guide walks through the complete setup: spinning up a VPS, installing Claude Code, creating persistent terminal sessions with Tmux, and wiring in a Telegram bot using the Channels plugin so you have full mobile access. If you’ve been looking for a way to run Claude Code 24/7 without babysitting your terminal, this is the setup.\n\n## What You’ll Need Before Starting\n\nThis is a technical setup. You don’t need to be a systems administrator, but you should be comfortable with the command line.\n\n**Prerequisites:**\n\n- A VPS from any provider (DigitalOcean, Hetzner, Linode, or Vultr all work — a $6/month instance is enough for most Claude Code workloads)\n- A local machine with an SSH client\n- An Anthropic API key with Claude access\n- A Telegram account\n- Node.js familiarity (for installation and basic troubleshooting)\n\nIf you’re using this setup for serious development work, pick a VPS with at least 2GB RAM. Claude Code’s context management can get memory-hungry on large codebases.\n\n## Set Up and Secure Your VPS\n\n### Choose and Provision Your Server\n\nSpin up an Ubuntu 22.04 or 24.04 LTS instance — it’s the most compatible with the packages you’ll need. A 2-core, 2GB RAM instance is a reasonable starting point.\n\nOnce provisioned, you’ll get an IP address and root credentials. Don’t stay as root longer than you need to.\n\n### Create a Non-Root User and Configure SSH\n\nSSH in as root first:\n\n```\nssh root@your-server-ip\n```\n\nCreate a new user with sudo privileges:\n\n```\nadduser youruser\nusermod -aG sudo youruser\n```\n\nSwitch to that user and set up SSH key authentication:\n\n```\nsu - youruser\nmkdir ~/.ssh\nchmod 700 ~/.ssh\n```\n\nOn your **local machine**, generate an SSH key pair if you don’t have one:\n\n```\nssh-keygen -t ed25519 -C \"your-email@example.com\"\n```\n\nCopy your public key to the server:\n\n```\nssh-copy-id youruser@your-server-ip\n```\n\nOnce key authentication is confirmed working, disable password login on the server by editing `/etc/ssh/sshd_config`\n\n:\n\n```\nsudo nano /etc/ssh/sshd_config\n```\n\nSet these lines:\n\n```\nPasswordAuthentication no\nPermitRootLogin no\n```\n\nThen restart SSH:\n\n```\nsudo systemctl restart sshd\n```\n\nThis closes off a major attack surface. Your server won’t accept brute-force password attempts anymore.\n\n### Set Up a Basic Firewall\n\n```\nsudo ufw allow OpenSSH\nsudo ufw enable\n```\n\nYou can open additional ports later if your Claude Code setup needs to serve web requests.\n\n## Install Claude Code on Your Server\n\n### Install Node.js\n\nClaude Code requires Node.js 18 or higher. The cleanest way to install it on Ubuntu is through NodeSource:\n\n```\ncurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -\nsudo apt-get install -y nodejs\n```\n\nVerify the install:\n\n```\nnode --version\nnpm --version\n```\n\n### Install Claude Code CLI\n\nClaude Code is Anthropic’s official CLI coding agent. Install it globally:\n\n```\nnpm install -g @anthropic-ai/claude-code\n```\n\n### Set Your API Key\n\nClaude Code reads your Anthropic API key from an environment variable. Add it to your shell profile so it persists across sessions:\n\n```\necho 'export ANTHROPIC_API_KEY=\"your-api-key-here\"' >> ~/.bashrc\nsource ~/.bashrc\n```\n\nReplace `your-api-key-here`\n\nwith your actual key from the [Anthropic Console](https://console.anthropic.com).\n\n### Test the Installation\n\nCreate a test directory and run Claude Code:\n\n```\nmkdir ~/test-project && cd ~/test-project\nclaude\n```\n\nIf you see the Claude Code prompt, the installation worked. Exit with `/exit`\n\nand move on.\n\n## Set Up Tmux for Persistent Sessions\n\nThis is the most important part of the setup. Without Tmux (or a similar terminal multiplexer), your Claude Code session dies the moment your SSH connection drops. With it, you can disconnect, close your laptop, and come back hours later to find everything exactly where you left it.\n\n### Install Tmux\n\n```\nsudo apt install tmux -y\n```\n\n### Essential Tmux Concepts\n\nTmux works around three things:\n\n**Sessions**— top-level containers that survive SSH disconnects** Windows**— tabs within a session** Panes**— split views within a window\n\nFor Claude Code, you typically want one named session per project.\n\n### Start a Named Session\n\n```\ntmux new-session -s claude-project\n```\n\nThis creates a session called `claude-project`\n\n. You can detach from it at any time with `Ctrl+B, D`\n\n— the session keeps running on the server.\n\n### Reattach to a Session\n\nWhen you SSH back in:\n\n```\ntmux attach -t claude-project\n```\n\nOr list all running sessions:\n\n```\ntmux ls\n```\n\n### Useful Tmux Shortcuts\n\n| Action | Shortcut |\n|---|---|\n| Detach session | `Ctrl+B, D` |\n| List sessions | `Ctrl+B, S` |\n| New window | `Ctrl+B, C` |\n| Switch window | `Ctrl+B, [0-9]` |\n| Split pane horizontally | `Ctrl+B, %` |\n| Split pane vertically | `Ctrl+B, \"` |\n| Scroll mode | `Ctrl+B, [` |\n\n## Remy doesn't write the code. It manages the agents who do.\n\nRemy runs the project. The specialists do the work. You work with the PM, not the implementers.\n\nA good practice: create one window for Claude Code, one for watching logs, and one for running tests. You can switch between them instantly without disconnecting.\n\n### Run Claude Code Inside Tmux\n\n```\ncd ~/your-project\nclaude\n```\n\nDetach and your session keeps running. Come back from any device with SSH access and you’ll pick up exactly where you left off.\n\n## Create Your Telegram Bot\n\nTelegram gives you a free, reliable messaging layer that works on every phone. You’ll use it as a command interface for your Claude Code session.\n\n### Create a Bot with BotFather\n\n- Open Telegram and search for\n`@BotFather`\n\n- Start a conversation and send\n`/newbot`\n\n- Follow the prompts — give your bot a name and a username (must end in\n`bot`\n\n) - BotFather will give you a\n**bot token** that looks like`123456789:ABCdefGhIjKlmNoPqrStUvWxYz`\n\nSave this token. You’ll need it shortly.\n\n### Get Your Chat ID\n\nYou need your personal Telegram chat ID so the bot only responds to you (not anyone who finds it).\n\nStart a conversation with your new bot by searching for it in Telegram, then send it any message. Now fetch your chat ID by visiting this URL in a browser:\n\n```\nhttps://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates\n```\n\nLook in the JSON response for `\"chat\":{\"id\":XXXXXXXXX}`\n\n. That number is your chat ID.\n\n## Connect Telegram to Claude Code with the Channels Plugin\n\nThe Channels plugin bridges your Telegram bot to Claude Code running inside Tmux. It watches your Telegram chat for incoming messages, routes them to the active Claude Code session, and sends the responses back to your phone.\n\n### Install the Channels Plugin\n\nThe Channels plugin integrates directly with Claude Code’s plugin system. From within your project directory:\n\n```\nclaude config add plugin channels\n```\n\nOr if you’re installing manually via npm:\n\n```\nnpm install -g claude-code-channels\n```\n\n### Configure the Plugin\n\nCreate a configuration file in your project:\n\n```\nnano ~/.claude/channels-config.json\n```\n\nAdd your Telegram credentials:\n\n```\n{\n  \"telegram\": {\n    \"botToken\": \"your-bot-token-here\",\n    \"allowedChatIds\": [123456789],\n    \"sessionName\": \"claude-project\"\n  },\n  \"tmux\": {\n    \"enabled\": true,\n    \"targetSession\": \"claude-project\",\n    \"targetWindow\": \"0\"\n  }\n}\n```\n\nReplace `your-bot-token-here`\n\nwith your actual token and `123456789`\n\nwith your chat ID.\n\n### Start the Channels Bridge\n\nInside your Tmux session (in a separate window from Claude Code), run:\n\n```\nclaude-channels start\n```\n\nOr if you installed it as a Claude Code plugin, activate it from within Claude Code:\n\n```\n/plugin channels start\n```\n\nThe bridge will confirm it’s connected to Telegram and listening.\n\n### Test the Connection\n\nSend a message to your bot from your phone:\n\n```\nHello Claude, what files are in this directory?\n```\n\nYou should see the message arrive in your Tmux window and Claude Code’s response come back to Telegram within seconds.\n\n## Harden Your Telegram Setup\n\nA few steps to make this production-safe:\n\n**Restrict bot access:** Your `allowedChatIds`\n\nlist is your first line of defense. Only your personal chat ID should be in there. If you want to share access with a team, add their IDs explicitly.\n\n**Rate limit commands:** Consider adding a cooldown between commands if you’re running tasks that take significant API credits. Most Channels plugin implementations support a `rateLimitSeconds`\n\nconfig option.\n\n**Log all interactions:** Enable logging so you have a record of what commands were sent and what Claude Code did with them. This is useful for debugging and auditing:\n\n```\n{\n  \"logging\": {\n    \"enabled\": true,\n    \"path\": \"/var/log/claude-channels.log\",\n    \"level\": \"info\"\n  }\n}\n```\n\n##\nPlans first.\n*Then code.*\n\nRemy writes the spec, manages the build, and ships the app.\n\n**Set up auto-restart:** If your VPS reboots, you want the bridge and your Tmux session to come back automatically. Use `systemd`\n\nto manage the channels process:\n\n```\nsudo nano /etc/systemd/system/claude-channels.service\n[Unit]\nDescription=Claude Code Telegram Bridge\nAfter=network.target\n\n[Service]\nType=simple\nUser=youruser\nWorkingDirectory=/home/youruser/your-project\nExecStart=/usr/bin/claude-channels start\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEnable and start:\n\n```\nsudo systemctl enable claude-channels\nsudo systemctl start claude-channels\n```\n\nFor Tmux persistence across reboots, look into [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) and the `tmux-resurrect`\n\nplugin — it saves and restores sessions automatically.\n\n## Tips for Your Mobile Workflow\n\nOnce everything is wired up, here’s how to use it effectively from your phone.\n\n**Use short commands.** Typing on mobile is slow. Keep instructions concise — Claude Code is good at inferring context from a running session, so you don’t need to repeat background information every time.\n\n**Check session state before sending commands.** Send a quick `what are you currently working on?`\n\nbefore issuing new instructions if you’ve been away for a while. This helps Claude Code orient itself.\n\n**Use Telegram’s voice messages.** Some Channels plugin configurations support converting voice messages to text before routing them to Claude Code. If yours does, speaking your instructions is much faster than typing.\n\n**Set up Telegram notifications for task completion.** Instruct Claude Code to send you a Telegram message when it finishes a long task. You can do this by including it in your prompt: “When you’re done, send a message to Telegram saying ‘Task complete.’” The Channels plugin will handle the routing.\n\n**Keep a commands reference.** Save a note in Telegram (to your Saved Messages) with the commands you use most often. A quick paste is faster than remembering syntax when you’re on your phone.\n\n## Where MindStudio Fits In\n\nOnce you have Claude Code running autonomously on a VPS, you’ll quickly hit a ceiling: Claude Code is great at writing and modifying code, but it can’t natively send emails, post to Slack, query your CRM, or trigger external workflows without extra plumbing.\n\nThat’s where MindStudio’s [Agent Skills Plugin](https://mindstudio.ai) comes in. It’s an npm SDK (`@mindstudio-ai/agent`\n\n) that gives any AI agent — including Claude Code running on your VPS — access to 120+ typed capabilities as simple method calls.\n\n```\nnpm install @mindstudio-ai/agent\n```\n\nFrom inside a Claude Code session, you can call things like:\n\n```\nawait agent.sendEmail({ to: \"team@yourcompany.com\", subject: \"Build complete\", body: result });\nawait agent.searchGoogle({ query: \"latest React 19 breaking changes\" });\nawait agent.runWorkflow({ workflowId: \"deploy-staging\" });\n```\n\nThe plugin handles rate limiting, retries, and authentication automatically. Claude Code stays focused on the code reasoning — MindStudio handles the integration layer.\n\nIf you want to go the other direction and build a no-code interface for monitoring or triggering your VPS-based Claude Code sessions, MindStudio’s visual builder lets you create that in under an hour. You could build a Slack-based interface, a scheduled trigger that kicks off Claude Code tasks at specific times, or a dashboard that reports on what Claude Code has been doing. You can try MindStudio free at [mindstudio.ai](https://mindstudio.ai).\n\n## Troubleshooting Common Issues\n\n### Claude Code Loses Context After Disconnect\n\n## Remy is new. The platform isn't.\n\nRemy is the latest expression of years of platform work. Not a hastily wrapped LLM.\n\nThis usually means you’re not running inside Tmux. Always start Claude Code with `tmux attach -t your-session`\n\nfirst. If you connect and the session is gone, check `tmux ls`\n\nto confirm it still exists.\n\n### Telegram Messages Aren’t Coming Through\n\n- Verify your bot token is correct — even one wrong character breaks it\n- Confirm your chat ID is listed in\n`allowedChatIds`\n\n- Check the channels bridge is running:\n`systemctl status claude-channels`\n\n- Look at the logs:\n`tail -f /var/log/claude-channels.log`\n\n### API Key Not Found\n\nIf Claude Code says it can’t find the API key, your environment variable isn’t loading. Run `echo $ANTHROPIC_API_KEY`\n\nin your session. If it’s empty, source your profile again:\n\n```\nsource ~/.bashrc\n```\n\nIf you’re running Claude Code via systemd, you’ll need to pass the environment variable in the service file using `Environment=ANTHROPIC_API_KEY=your-key`\n\n.\n\n### SSH Connection Keeps Dropping\n\nAdd these lines to your local `~/.ssh/config`\n\nto keep connections alive:\n\n```\nHost your-server-ip\n  ServerAliveInterval 60\n  ServerAliveCountMax 3\n```\n\nThis sends a keepalive packet every 60 seconds, preventing idle connection timeouts.\n\n## Frequently Asked Questions\n\n### Does Claude Code work on any VPS provider?\n\nYes. Claude Code is a Node.js application that runs anywhere Node.js 18+ is supported. Ubuntu 22.04 on any provider — DigitalOcean, Hetzner, Vultr, Linode, AWS EC2, or Google Cloud — works fine. Pick based on price and region.\n\n### Is it safe to store my Anthropic API key on a VPS?\n\nIt’s reasonably safe if you’ve followed proper server hardening (SSH key auth only, no root login, firewall enabled). For production setups, use a secrets manager like HashiCorp Vault or your cloud provider’s secrets service rather than storing the key in `.bashrc`\n\n. Never commit the key to version control.\n\n### Can I run multiple Claude Code sessions simultaneously?\n\nYes. Create separate Tmux sessions for each project:\n\n```\ntmux new-session -s project-a\ntmux new-session -s project-b\n```\n\nYou can configure the Channels plugin to route different Telegram commands to different sessions based on a prefix — for example, `/a do this`\n\ngoes to `project-a`\n\nand `/b do this`\n\ngoes to `project-b`\n\n.\n\n### How much does this setup cost?\n\nA basic VPS runs $5–10/month. Claude Code itself is billed per API token through your Anthropic account — costs vary widely depending on how intensively you use it. Long autonomous coding sessions with large codebases can use significant token budget, so set usage limits in your Anthropic Console to avoid surprises.\n\n### Can I use this with other AI coding agents, not just Claude Code?\n\nThe Tmux + Telegram bridge approach works with any terminal-based AI agent. The Channels plugin is specifically designed for Claude Code, but the underlying architecture — persistent Tmux sessions piped through a Telegram bot — can be adapted for tools like [Aider](https://aider.chat) or custom agent setups with minor modification.\n\n### What’s the best way to handle long-running Claude Code tasks?\n\nGive Claude Code clear stopping conditions in your initial prompt. Something like “work on this until the tests pass, then stop and send a Telegram message.” Without stopping conditions, agents can loop or get stuck. Also set up Tmux logging (`tmux pipe-pane`\n\n) so you have a full record of what happened, which is useful when you check in from your phone.\n\n## Key Takeaways\n\n- A VPS with Tmux gives you persistent, 24/7 Claude Code sessions that survive SSH disconnects and let you work asynchronously.\n- Telegram bots provide a lightweight mobile interface — no custom app required, just a bot token and a chat ID.\n- The Channels plugin bridges your Telegram messages directly to your Claude Code session, routing commands and returning responses to your phone.\n- Securing the setup (SSH keys, restricted chat IDs, systemd for auto-restart) is straightforward and worth doing before you rely on it for real work.\n- MindStudio’s Agent Skills Plugin extends Claude Code’s reach beyond code changes to emails, external APIs, and full workflow automation — with a single npm install.\n\n### Built like a system. Not vibe-coded.\n\nRemy manages the project — every layer architected, not stitched together at the last second.\n\nIf you want a no-code layer on top of your autonomous coding setup — a dashboard, a scheduled trigger, or a way to connect Claude Code’s output to your business tools — [MindStudio](https://mindstudio.ai) is worth exploring. You can start free and build your first integration in under an hour.", "url": "https://wpnews.pro/news/how-to-run-claude-code-on-a-vps-with-telegram-mobile-access", "canonical_source": "https://www.mindstudio.ai/blog/run-claude-code-vps-telegram-mobile-access/", "published_at": "2026-06-10 00:00:00+00:00", "updated_at": "2026-06-11 19:48:35.077946+00:00", "lang": "en", "topics": ["ai-tools", "ai-infrastructure", "ai-products", "large-language-models", "generative-ai"], "entities": ["Claude Code", "Anthropic", "DigitalOcean", "Hetzner", "Linode", "Vultr", "Telegram", "Tmux"], "alternates": {"html": "https://wpnews.pro/news/how-to-run-claude-code-on-a-vps-with-telegram-mobile-access", "markdown": "https://wpnews.pro/news/how-to-run-claude-code-on-a-vps-with-telegram-mobile-access.md", "text": "https://wpnews.pro/news/how-to-run-claude-code-on-a-vps-with-telegram-mobile-access.txt", "jsonld": "https://wpnews.pro/news/how-to-run-claude-code-on-a-vps-with-telegram-mobile-access.jsonld"}}