agentport

Guide · Codex CLI · Claude Code

Run Codex CLI and Claude Code on a VPS, and use them from your phone

Codex CLI and Claude Code are terminal coding agents. On a laptop they stop when the lid closes. On a small always-on server they keep working while you are away, and you can check on them from any device. This guide covers the setup step by step, and is honest about where AgentPort fits today.

Where AgentPort stands today. AgentPort's browser chat currently runs Grok Build and Google Antigravity. Codex CLI and Claude Code are on the roadmap (up next, after routines and webhook triggers), but they do not run inside AgentPort yet. Everything below works without AgentPort.

What you need

Create a normal user for the agents instead of working as root, and keep the projects they work on in git.

Step 1: Install Codex CLI and sign in without a browser

Install it with npm (Node.js needed) or OpenAI's own installer from the Codex docs:

npm install -g @openai/codex
codex --version

The normal codex login opens a browser and waits for a redirect to localhost, which fails on a server you reached over SSH. Use the device code flow instead:

codex login --device-auth

It prints a link and a one-time code. Open the link on your laptop or phone, sign in with ChatGPT and enter the code; the server picks it up by itself. Device code login is marked beta and has to be turned on first in your ChatGPT security settings (or by your workspace admin). If you use an API key instead:

printenv OPENAI_API_KEY | codex login --with-api-key

Official details: Codex authentication.

Step 2: Install Claude Code and sign in

Anthropic's native installer works on Ubuntu 20.04+, Debian 10+ and Alpine, and keeps itself updated:

curl -fsSL https://claude.ai/install.sh | bash
claude --version

Then run claude in a project folder and follow the sign-in prompts. On a server without a browser it gives you a sign-in link to open on another device. To use an Anthropic API key instead, set ANTHROPIC_API_KEY and approve the key when Claude Code asks. Official details: Claude Code setup.

Step 3: Keep the agent running with tmux

Without tmux, the agent stops as soon as your SSH connection drops. Start each agent in a named session inside your project:

cd ~/projects/my-app
tmux new -s codex      # then run: codex
# or
tmux new -s claude     # then run: claude

Give it a task, then detach with Ctrl-b then d. Close your laptop; the task keeps going. Reattach later from any computer:

ssh you@your-server -t tmux attach -t codex

Why this works, and why tmux on the laptop itself does not: Keep a coding agent running after you close your laptop.

Step 4: Use them from your phone

Any agent: an SSH app

Install an SSH client such as Termius or Blink Shell (iPhone) or Termux (Android), add your server's key, and run tmux attach -t codex. It works for every terminal agent, but a full-screen terminal on a phone keyboard is slow going: special keys are hard to reach and nothing tells you when the agent is waiting for you. A private network such as Tailscale lets you skip exposing SSH to the whole internet.

Claude Code: Remote Control

Claude Code has a built-in Remote Control mode. Inside the tmux session, type /remote-control, then open the session in the Claude app (iOS or Android) or at claude.ai/code with the same account. Claude keeps running on your server and the app is a window into it. It needs a claude.ai plan login rather than an API key, and Anthropic keeps the session transcript on its servers while it is connected. See Anthropic's Remote Control docs.

Where AgentPort fits

AgentPort is a browser chat for coding agents that run on your own computer or VPS. One install command starts a Docker container on the server, opens a secure outbound link (no ports to open), and from then on you chat with the agent from any browser, including your phone, with approval buttons, chat history and a diff of changed files. Your browser connects straight to your server; AgentPort's cloud only handles sign-in and your list of computers.

The same server can run both setups side by side: Codex or Claude Code in tmux, and Grok Build through AgentPort.

FAQ

How do I log in to Codex CLI on a headless server?

Run codex login --device-auth, open the printed link on any device and enter the code. Turn on device code login in your ChatGPT security settings first. With an API key, pipe it into codex login --with-api-key.

How much server do I need for Claude Code or Codex?

Anthropic lists 4 GB of RAM or more for Claude Code. The agents send the heavy work to the model provider, so the server mostly needs enough memory for the agent plus your project's own build and tests.

Does the agent keep running when I close my laptop?

Yes, if it runs on the server inside tmux (or screen). If it runs on the laptop, closing the lid stops it.

Can I use Codex CLI or Claude Code in AgentPort?

Not yet. AgentPort runs Grok Build and Google Antigravity today. Codex CLI and Claude Code are planned; see the roadmap.

Do I pay AgentPort for model usage?

No. You use your own plan or API key with OpenAI, Anthropic, xAI or Google and pay them directly. AgentPort Free covers 1 computer; Pro is $27/month for up to 3.

Try it on your own computer

The Free plan covers 1 computer. Pro is $27/month for up to 3. You bring the AI login and pay that provider directly.