Claude Code on a VPS without SSH
You can let Claude Code run commands and long jobs on a VPS without opening a port or exposing SSH to the internet. You install a small host agent on the VPS. It makes one outbound connection to aicommander.dev, and Claude Code reaches it through the AI Commander MCP server. AI Commander works alongside Claude Code: Claude stays the interface you talk to, and AI Commander is not a replacement for Claude or for SSH-hardening advice.
How the connection works
The host agent opens a single outbound WebSocket to the relay over TLS and keeps it open. Nothing on the VPS listens for incoming connections, so
there is no inbound port to forward and no SSH daemon that must face the internet. The VPS only needs outbound HTTPS and WebSocket (wss://) access to aicommander.dev; a firewall or proxy that blocks WebSocket upgrades will stop the agent from connecting.
Claude Code talks to the relay's MCP endpoint, https://aicommander.dev/mcp, and the relay passes each command to the agent over its
existing connection. Details: security model and how it works. For the general, client-neutral version of this idea see operate cloud VMs without exposing SSH; this page is the Claude Code setup.
1. Install the host agent on the VPS
Use the signed installer from Install the host agent on each box (Linux x86_64 and arm64 with systemd). It
installs the agent as a systemd service called aicommander-agent that starts again after a reboot. When it is running, print the
session code on the VPS:
sudo aicommander-agent status --reveal
Logs and plain status show only a masked code; the full value is printed only with --reveal. To watch the agent connect,
run journalctl -u aicommander-agent -f. If you only want a quick test, npx @aicommander/agent (Node 20 or newer) does a
foreground run that stops when the terminal closes and gives no service or reboot persistence.
2. Add AI Commander to Claude Code
On the machine where you run Claude Code (your laptop, or another box), attach the MCP server:
claude mcp add --transport http aicommander https://aicommander.dev/mcp claude mcp list
If it needs you to sign in, run /mcp inside Claude Code and follow the browser steps; the sign-in ties the connection to your AI Commander account. To make it available in every project, add it with claude mcp add --transport http --scope user aicommander https://aicommander.dev/mcp. Then give Claude Code the session code you printed in step 1 (or save the machine under an alias in the dashboard) and ask it to check that the VPS is online; the code is what identifies the machine, and the sign-in alone does not add the VPS. More on this setup: AI Commander with Claude Code and the
MCP stack for Claude Code.
3. Use it from the Claude phone app
In the Claude app, AI Commander is a custom connector for the same URL. Add it on claude.ai or in Claude Desktop under
Customize → Connectors → Add custom connector, enter https://aicommander.dev/mcp, leave authentication on its default and
complete the one-time browser sign-in. Anthropic notes that installing connectors on mobile is in beta and that web and Desktop remain the primary
path for custom connectors, so add it there first, then open the Claude app on your phone. Claude reaches custom connectors from Anthropic's cloud,
which works here because the AI Commander endpoint is public; your VPS stays outbound-only. Claude Code's own Remote Control feature is covered in
AI Commander with Claude Code.
4. Run remote jobs
A quick command runs with remote_exec. Anything long should be a detached job started with
remote_job_start: it returns a job ID at once, writes its output to a file on the VPS, and keeps running through a network drop, the
client disconnecting or the conversation ending. On Linux each job runs in its own transient systemd scope, so restarting the host agent does not stop
it; that needs a systemd host with the agent running as root.
To run Claude Code itself on the VPS, install and sign in to Claude Code there, then ask for a job that runs claude -p in your repo and
collect the result later. See Remote coding agents for that pattern.
5. Check logs and status
Ask Claude Code, or the Claude app, in plain words. It uses these tools:
| Tool | What you get |
|---|---|
session_status | Whether the host agent on that machine is online and ready |
remote_job_list | Jobs running now, plus finished ones still retained (about a week) |
remote_job_status | One job's state: running, exited (with its exit code) or unknown. Unknown means no reliable exit code, for example after the process was killed; check the logs and any output files before treating the job as successful |
remote_job_logs | A slice of the job's combined stdout and stderr; the last 200 lines by default, at most 256 KiB per reply, paged forward for longer logs |
remote_job_cancel | Stops a job and its whole process tree |
For the agent service itself, use journalctl -u aicommander-agent -f on the VPS. If the machine shows offline, see Troubleshooting.
What this does and does not change about SSH
AI Commander gives Claude Code a path to the VPS that needs no inbound port. It does not harden, replace or disable SSH, and it is not advice to skip SSH hardening: if you keep SSH for yourself, your backups or other tools, keep following the usual guidance (keys only, no root login, a firewall or private network in front of it). The connection also depends on the VPS being able to make outbound HTTPS and WebSocket connections to aicommander.dev.
FAQ
Try it on one VPS
Install the host agent, run claude mcp add --transport http aicommander https://aicommander.dev/mcp, and ask Claude Code to run uname -a on the box.
Claude and Claude Code are trademarks of Anthropic; AI Commander is not affiliated with, endorsed by, or sponsored by Anthropic. Connector details checked against the Claude Help Center and the Claude Code MCP documentation on 2026-10-17.