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.

Read this first. This is remote shell access, not a sandbox: a command Claude Code sends runs with the permissions of the agent on the VPS, which is root by default on Linux. Treat the machine's session code like a password, and only give Claude Code access to boxes you are willing to let it change.

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.

Prompt — Claude Code or the Claude app
On my VPS, start a job in /srv/app named nightly-build that runs: npm ci && npm run build Give me the job ID and tell me when it has finished.

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:

ToolWhat you get
session_statusWhether the host agent on that machine is online and ready
remote_job_listJobs running now, plus finished ones still retained (about a week)
remote_job_statusOne 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_logsA 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_cancelStops 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

Can Claude Code manage a VPS without SSH?
Yes, with AI Commander alongside it. You install the host agent on the VPS; it opens one outbound connection to aicommander.dev and accepts no inbound connections, so the VPS needs no open port and no public SSH. Claude Code, with the AI Commander MCP server added, then runs commands and detached jobs on that VPS through the relay.
Do I have to close SSH on the VPS to use this?
No. AI Commander does not replace SSH or SSH hardening advice, and it does not change your SSH configuration. If you keep SSH for other reasons, keep following the usual hardening guidance. The point is that this connection path needs no inbound port at all, so you can choose to leave SSH closed, restricted to a private network, or open as before.
How do I add AI Commander to Claude Code?
Run claude mcp add --transport http aicommander https://aicommander.dev/mcp, then claude mcp list to check it is attached. If it asks you to sign in, run /mcp inside Claude Code and follow the browser sign-in.
Can I use it from the Claude phone app?
Yes, as a custom connector. Add https://aicommander.dev/mcp under Customize → Connectors → Add custom connector on claude.ai or Claude Desktop and complete the one-time browser sign-in. Anthropic's help center says installing connectors on mobile is in beta and that web and Desktop remain the primary path for custom connectors, so add it there first and then use it from the phone app. Custom connectors are reached from Anthropic's cloud, which works here because the AI Commander MCP endpoint is public.
Does the job keep running if I close Claude Code or lose my connection?
Yes, if you start it with remote_job_start. A detached job's output goes to a file on the VPS and the job keeps running through a network drop, the client disconnecting and 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.
How do I check logs?
Ask Claude Code for the job's status and logs. It uses remote_job_status for the state (running, exited with an exit code, or unknown) and remote_job_logs for the output; by default you get the last 200 lines, and each reply is at most 256 KiB, so longer logs are read in pages. For the host agent itself, run journalctl -u aicommander-agent -f on the VPS; it shows only the masked session code.
Is AI Commander an alternative to Claude Code?
No. Claude Code (or the Claude app) stays the interface you talk to; AI Commander is the MCP server and host agent that lets it act on machines you own.

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.