cd /news/ai-tools/how-to-run-claude-code-on-a-vps-with… · home topics ai-tools article
[ARTICLE · art-24394] src=mindstudio.ai pub= topic=ai-tools verified=true sentiment=↑ positive

How to Run Claude Code on a VPS with Telegram Mobile Access

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.

read14 min publishedJun 10, 2026

Run 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.

Why Running Claude Code on a VPS Makes Sense #

Running 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.

This 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.

What You’ll Need Before Starting #

This is a technical setup. You don’t need to be a systems administrator, but you should be comfortable with the command line.

Prerequisites:

  • A VPS from any provider (DigitalOcean, Hetzner, Linode, or Vultr all work — a $6/month instance is enough for most Claude Code workloads)
  • A local machine with an SSH client
  • An Anthropic API key with Claude access
  • A Telegram account
  • Node.js familiarity (for installation and basic troubleshooting)

If 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.

Set Up and Secure Your VPS #

Choose and Provision Your Server

Spin 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.

Once provisioned, you’ll get an IP address and root credentials. Don’t stay as root longer than you need to.

Create a Non-Root User and Configure SSH

SSH in as root first:

ssh root@your-server-ip

Create a new user with sudo privileges:

adduser youruser
usermod -aG sudo youruser

Switch to that user and set up SSH key authentication:

su - youruser
mkdir ~/.ssh
chmod 700 ~/.ssh

On your local machine, generate an SSH key pair if you don’t have one:

ssh-keygen -t ed25519 -C "your-email@example.com"

Copy your public key to the server:

ssh-copy-id youruser@your-server-ip

Once key authentication is confirmed working, disable password login on the server by editing /etc/ssh/sshd_config

:

sudo nano /etc/ssh/sshd_config

Set these lines:

PasswordAuthentication no
PermitRootLogin no

Then restart SSH:

sudo systemctl restart sshd

This closes off a major attack surface. Your server won’t accept brute-force password attempts anymore.

Set Up a Basic Firewall

sudo ufw allow OpenSSH
sudo ufw enable

You can open additional ports later if your Claude Code setup needs to serve web requests.

Install Claude Code on Your Server #

Install Node.js

Claude Code requires Node.js 18 or higher. The cleanest way to install it on Ubuntu is through NodeSource:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Verify the install:

node --version
npm --version

Install Claude Code CLI

Claude Code is Anthropic’s official CLI coding agent. Install it globally:

npm install -g @anthropic-ai/claude-code

Set Your API Key

Claude Code reads your Anthropic API key from an environment variable. Add it to your shell profile so it persists across sessions:

echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc

Replace your-api-key-here

with your actual key from the Anthropic Console.

Test the Installation

Create a test directory and run Claude Code:

mkdir ~/test-project && cd ~/test-project
claude

If you see the Claude Code prompt, the installation worked. Exit with /exit

and move on.

Set Up Tmux for Persistent Sessions #

This 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.

Install Tmux

sudo apt install tmux -y

Essential Tmux Concepts

Tmux works around three things:

Sessions— top-level containers that survive SSH disconnects** Windows**— tabs within a session** Panes**— split views within a window

For Claude Code, you typically want one named session per project.

Start a Named Session

tmux new-session -s claude-project

This creates a session called claude-project

. You can detach from it at any time with Ctrl+B, D

— the session keeps running on the server.

Reattach to a Session

When you SSH back in:

tmux attach -t claude-project

Or list all running sessions:

tmux ls

Useful Tmux Shortcuts

Action Shortcut
Detach session Ctrl+B, D
List sessions Ctrl+B, S
New window Ctrl+B, C
Switch window Ctrl+B, [0-9]
Split pane horizontally Ctrl+B, %
Split pane vertically Ctrl+B, "
Scroll mode Ctrl+B, [

Remy doesn't write the code. It manages the agents who do. #

Remy runs the project. The specialists do the work. You work with the PM, not the implementers.

A 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.

Run Claude Code Inside Tmux

cd ~/your-project
claude

Detach and your session keeps running. Come back from any device with SSH access and you’ll pick up exactly where you left off.

Create Your Telegram Bot #

Telegram 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.

Create a Bot with BotFather

  • Open Telegram and search for @BotFather

  • Start a conversation and send /newbot

  • Follow the prompts — give your bot a name and a username (must end in bot

) - BotFather will give you a bot token that looks like123456789:ABCdefGhIjKlmNoPqrStUvWxYz

Save this token. You’ll need it shortly.

Get Your Chat ID

You need your personal Telegram chat ID so the bot only responds to you (not anyone who finds it).

Start 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:

https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates

Look in the JSON response for "chat":{"id":XXXXXXXXX}

. That number is your chat ID.

Connect Telegram to Claude Code with the Channels Plugin #

The 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.

Install the Channels Plugin

The Channels plugin integrates directly with Claude Code’s plugin system. From within your project directory:

claude config add plugin channels

Or if you’re installing manually via npm:

npm install -g claude-code-channels

Configure the Plugin

Create a configuration file in your project:

nano ~/.claude/channels-config.json

Add your Telegram credentials:

{
  "telegram": {
    "botToken": "your-bot-token-here",
    "allowedChatIds": [123456789],
    "sessionName": "claude-project"
  },
  "tmux": {
    "enabled": true,
    "targetSession": "claude-project",
    "targetWindow": "0"
  }
}

Replace your-bot-token-here

with your actual token and 123456789

with your chat ID.

Start the Channels Bridge

Inside your Tmux session (in a separate window from Claude Code), run:

claude-channels start

Or if you installed it as a Claude Code plugin, activate it from within Claude Code:

/plugin channels start

The bridge will confirm it’s connected to Telegram and listening.

Test the Connection

Send a message to your bot from your phone:

Hello Claude, what files are in this directory?

You should see the message arrive in your Tmux window and Claude Code’s response come back to Telegram within seconds.

Harden Your Telegram Setup #

A few steps to make this production-safe:

Restrict bot access: Your allowedChatIds

list 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.

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

config option.

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:

{
  "logging": {
    "enabled": true,
    "path": "/var/log/claude-channels.log",
    "level": "info"
  }
}

#

Plans first. Then code.

Remy writes the spec, manages the build, and ships the app.

Set up auto-restart: If your VPS reboots, you want the bridge and your Tmux session to come back automatically. Use systemd

to manage the channels process:

sudo nano /etc/systemd/system/claude-channels.service
[Unit]
Description=Claude Code Telegram Bridge
After=network.target

[Service]
Type=simple
User=youruser
WorkingDirectory=/home/youruser/your-project
ExecStart=/usr/bin/claude-channels start
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl enable claude-channels
sudo systemctl start claude-channels

For Tmux persistence across reboots, look into Tmux Plugin Manager and the tmux-resurrect

plugin — it saves and restores sessions automatically.

Tips for Your Mobile Workflow #

Once everything is wired up, here’s how to use it effectively from your phone.

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.

Check session state before sending commands. Send a quick what are you currently working on?

before issuing new instructions if you’ve been away for a while. This helps Claude Code orient itself.

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.

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.

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.

Where MindStudio Fits In #

Once 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.

That’s where MindStudio’s Agent Skills Plugin comes in. It’s an npm SDK (@mindstudio-ai/agent

) that gives any AI agent — including Claude Code running on your VPS — access to 120+ typed capabilities as simple method calls.

npm install @mindstudio-ai/agent

From inside a Claude Code session, you can call things like:

await agent.sendEmail({ to: "team@yourcompany.com", subject: "Build complete", body: result });
await agent.searchGoogle({ query: "latest React 19 breaking changes" });
await agent.runWorkflow({ workflowId: "deploy-staging" });

The plugin handles rate limiting, retries, and authentication automatically. Claude Code stays focused on the code reasoning — MindStudio handles the integration layer.

If 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.

Troubleshooting Common Issues #

Claude Code Loses Context After Disconnect

Remy is new. The platform isn't. #

Remy is the latest expression of years of platform work. Not a hastily wrapped LLM.

This usually means you’re not running inside Tmux. Always start Claude Code with tmux attach -t your-session

first. If you connect and the session is gone, check tmux ls

to confirm it still exists.

Telegram Messages Aren’t Coming Through

  • Verify your bot token is correct — even one wrong character breaks it

  • Confirm your chat ID is listed in allowedChatIds

  • Check the channels bridge is running: systemctl status claude-channels

  • Look at the logs: tail -f /var/log/claude-channels.log

API Key Not Found

If Claude Code says it can’t find the API key, your environment variable isn’t . Run echo $ANTHROPIC_API_KEY

in your session. If it’s empty, source your profile again:

source ~/.bashrc

If 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

.

SSH Connection Keeps Dropping

Add these lines to your local ~/.ssh/config

to keep connections alive:

Host your-server-ip
  ServerAliveInterval 60
  ServerAliveCountMax 3

This sends a keepalive packet every 60 seconds, preventing idle connection timeouts.

Frequently Asked Questions #

Does Claude Code work on any VPS provider?

Yes. 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.

Is it safe to store my Anthropic API key on a VPS?

It’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

. Never commit the key to version control.

Can I run multiple Claude Code sessions simultaneously?

Yes. Create separate Tmux sessions for each project:

tmux new-session -s project-a
tmux new-session -s project-b

You can configure the Channels plugin to route different Telegram commands to different sessions based on a prefix — for example, /a do this

goes to project-a

and /b do this

goes to project-b

.

How much does this setup cost?

A 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.

Can I use this with other AI coding agents, not just Claude Code?

The 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 or custom agent setups with minor modification.

What’s the best way to handle long-running Claude Code tasks?

Give 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

) so you have a full record of what happened, which is useful when you check in from your phone.

Key Takeaways #

  • A VPS with Tmux gives you persistent, 24/7 Claude Code sessions that survive SSH disconnects and let you work asynchronously.
  • Telegram bots provide a lightweight mobile interface — no custom app required, just a bot token and a chat ID.
  • The Channels plugin bridges your Telegram messages directly to your Claude Code session, routing commands and returning responses to your phone.
  • 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.
  • 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.

Built like a system. Not vibe-coded.

Remy manages the project — every layer architected, not stitched together at the last second.

If 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 is worth exploring. You can start free and build your first integration in under an hour.

── more in #ai-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-run-claude-co…] indexed:0 read:14min 2026-06-10 ·