Let an AI agent reach a machine behind NAT
You can give a locally installed Claude Code or Codex session access to a machine with no inbound port at all — a home server, a box behind CGNAT, a VM inside a corporate network. The machine runs a Cmdop agent that dials out to a relay and keeps that connection open, so nothing has to dial in: no port forwarding, no VPN, and no SSH daemon exposed to the internet. The assistant then reaches it through Cmdop’s fleet tools.
This guide covers the case where the target machine is the unreachable one. If both machines are already reachable and you only want to wire up the assistant, Give an assistant fleet access is the shorter path.
What you need
- The target machine: any macOS or Linux host you can log into once, locally or through whatever access you have today. It needs outbound HTTPS and nothing else — no static IP, no DNS record, no firewall change.
- The machine you work from: your laptop, with Claude Code or Codex installed and a Cmdop agent of its own.
- A fleet join key from the relay both machines will join.
cmdop server join-keyprints it on the relay host.
Both machines join the same fleet. That shared membership — not a network route — is what makes one reachable from the other.
1. Join the target machine to your fleet
On the machine behind NAT, install Cmdop and join:
curl -fsSL https://install.cmdop.com | sh
cmdop join <join-key>
cmdop agent startcmdop join stores the credential; cmdop agent start brings the agent up so
it holds an outbound connection to the relay. Nothing here opens a port, and you
do not need to know the machine’s address — it announces itself.
If the machine should stay online across reboots, install it as a service:
cmdop service install2. Confirm it is actually reachable
From the machine you work from — not from the target — list the fleet:
cmdop connect --listThe target should appear as online. This is the verification step: if it is listed and online here, the NAT problem is solved, and everything below is just wiring the assistant to it. If it is missing, see Machines — the picker hides offline machines and this machine by design.
Prove the machine actually answers before involving an assistant, by asking its agent for something small:
cmdop fleet <machine>3. Give the assistant access
On the machine you work from, register the fleet MCP server with your assistant:
cmdop mcp install --agent claude # or: --agent codexRestart the assistant so it picks up the tools. For Claude Code this step is usually automatic — see Give an assistant fleet access for what each engine does by default.
4. Verify from inside the assistant
Ask the assistant to list your machines. It should name the target. Then ask it to do something small and specific there:
Run `df -h` on <machine> and tell me if anything is above 80%.If the machine appears in the list but a call fails, the network was never the problem — check whether the machine is armed with a connection PIN, which the assistant must pass. See MCP troubleshooting.
What this does not do
- It does not put the machine on a network. Other hosts cannot reach its services by IP. If you need service-to-service connectivity, that is a VPN or mesh network’s job — see Where Cmdop fits.
- It does not expose a public URL. If you want the internet to reach a web app running on that machine, you want a tunnel, not this.
- It does not grant the assistant unlimited authority. Tool activity on the target is bounded by that machine’s own permission policy, and an armed machine additionally requires its connection PIN.
Common questions
How do I give an AI agent access to a server behind NAT?
Install the Cmdop agent on the server and join it to a fleet with cmdop join.
The agent dials out to the relay and stays connected, so no inbound port, port
forwarding, or VPN is needed. Then register the fleet MCP server with Claude
Code or Codex on the machine you work from, and the assistant can reach it.
Can Claude Code run commands on a remote machine?
Yes, through Cmdop’s fleet MCP server. Claude Code gets tools to list your machines, ask a machine’s agent to do work, and run a shell command on it. These reach other machines across the relay and are separate from Claude Code’s own local shell.
Do I need to open a firewall port on the target machine?
No. The target needs outbound HTTPS and nothing else — no static IP, no DNS record, and no firewall change. It announces itself to the relay rather than waiting to be contacted.
Related
- Give an assistant fleet access — the tools, and working across several machines
- Run an AI agent on a server without SSH — the server-operations variant
- Fleet MCP tools — what each tool does
- How CMDOP works — why the outbound model reaches
- Security model — credentials, permissions, and external MCP boundaries
- Machines — when a machine is not listed