---
title: "Run Codex remote control on a server"
description: "Run Codex's remote-control daemon on an always-on exe.dev VM and steer it from the ChatGPT app on your phone or desktop while your laptop sleeps."
url: https://exe.dev/deploy/codex-remote-control
category: "AI agents"
updated: 2026-10-31
---

# Run Codex remote control on a server

Codex on an always-on VM, steered from the ChatGPT app on your phone.

- **Software:** Codex Remote Control (https://openai.com/codex/)
- **Source:** https://github.com/openai/codex
- **License:** Apache-2.0
- **Time:** 5 minutes
- **Example VM name:** `my-codex-rc` (yours will differ; on the VM, `hostname` prints it)
- **Machine-readable:** https://exe.dev/deploy/codex-remote-control/manifest.json

## What you get

- The Codex app-server daemon with remote control turned on, run by a systemd user service and back after a reboot
- A Git project at `~/project` for Codex to work in

Running on the VM:

- **Codex app-server daemon**: preinstalled Codex, started by a systemd user service, with remote control on, data in `~/.codex`
- **OpenAI's relay**: the VM connects out to it; no port is opened on the VM
- **Your project**: a Git repository, data in `~/project`

How it is reached:

- the ChatGPT app (private): your phone or computer, signed in to the same ChatGPT account as the VM
- ssh my-codex-rc.exe.xyz (private): your terminal, for signing in, pairing and upkeep

## Deploy with Shelley

Open https://exe.dev/new?prompt=Set%20up%20Codex%20Remote%20Control%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe.dev%2Fdeploy%2Fcodex-remote-control.md%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-codex-rc.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-codex-rc.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20The%20Codex%20app-server%20daemon%20with%20remote%20control%20turned%20on%2C%20run%20by%20a%20systemd%20user%20service%20and%20back%20after%20a%20reboot%0A-%20A%20Git%20project%20at%20%60~%2Fproject%60%20for%20Codex%20to%20work%20in%0A%0ARun%20the%20VM-side%20commands%20in%20%22Set%20up%20the%20VM%22%20only%3B%20skip%20creating%20the%20VM.%0ADo%20not%20run%20%60codex%20login%60%2C%20%60codex%20logout%60%2C%20%60exeuntu%20configure%20codex%60%20or%0A%60codex%20remote-control%20pair%60%3A%20signing%20in%20to%20ChatGPT%20and%20pairing%20are%20the%0Aowner%27s%20steps%2C%20and%20pairing%20codes%20expire%20within%20minutes.%20Verify%20that%0A%60systemctl%20--user%20is-active%20codex-remote-control%60%20prints%20%60active%60%20and%0Athat%20%60codex%20app-server%20daemon%20version%60%20reports%20%60%22status%22%3A%22running%22%60.%0ASkip%20the%20later%20sections%20and%20the%20FAQ.%20Finish%20by%20telling%20the%20owner%20to%20run%0A%60ssh%20my-codex-rc.exe.xyz%60%20with%20this%20VM%27s%20name%20and%20follow%20%22Sign%20in%20and%0Apair%20your%20phone%22.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open.%0A to create a VM whose agent, Shelley, follows this recipe. From a terminal:

```sh
curl -fsSL https://exe.dev/deploy/codex-remote-control/prompt.txt | ssh exe.dev new --prompt=/dev/stdin
```

Or follow the steps below by hand.

Codex can run as a background service, the app-server daemon, that you
control from the ChatGPT app: start a chat in a project, answer Codex's
questions, approve commands and read diffs from your phone. OpenAI's guide
puts that service on your Mac or PC, which then has to stay awake. Put it on
an exe.dev VM instead and it's always on, on a disk that keeps your
projects, chats and sign-in, and the VM opens no ports: it connects out to
OpenAI's relay.

Codex comes preinstalled on exe.dev. You need a ChatGPT account with Codex
access and the ChatGPT app on your phone. Remote control from the Codex CLI
is marked experimental.

## Set up the VM

On your computer, create a VM and connect. Pick any free name: the VM shows
up in the ChatGPT app under it. If you've already clicked Deploy or have a
VM, skip the first command and use its name:

```bash
ssh exe.dev new --name=my-codex-rc
ssh my-codex-rc.exe.xyz
```

On the VM, turn on remote control for Codex's daemon and have a systemd
user service start the daemon on every boot. Codex's own daemon doesn't
survive a reboot by itself:

```bash
codex app-server daemon enable-remote-control
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/codex-remote-control.service <<'EOF'
[Unit]
Description=Codex app-server daemon with remote control
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/codex app-server daemon start
ExecStop=/usr/local/bin/codex app-server daemon stop

[Install]
WantedBy=default.target
EOF
systemctl --user daemon-reload
systemctl --user enable --now codex-remote-control
git init ~/project
```

The first command copies Codex into `~/.codex/packages/app-server-daemon`,
where the daemon runs and updates itself. Check that it's up: the service is
`active` and the daemon reports `"status":"running"`:

```bash
systemctl --user is-active codex-remote-control
codex app-server daemon version
```

exe.dev VMs keep user services running without a login, so this survives
reboots and disconnects.

## Sign in and pair your phone

Remote control goes through your ChatGPT account, so Codex on the VM signs
in to it. First, turn on device code login in your
ChatGPT security settings (a workspace admin does this in workspace
permissions). Then, on the VM:

```bash
codex login --device-auth
```

Open the link it prints on your computer or phone, sign in, and enter the
code. If you've connected this VM's Codex to exe.dev's LLM integration
before, delete the `model_provider = "exe-llm"` line from
`~/.codex/config.toml` too, so Codex uses your ChatGPT plan.

Restart the daemon so it picks up the sign-in, then check the connection:

```bash
systemctl --user restart codex-remote-control
codex remote-control start
```

It says `This machine is available for remote control as my-codex-rc.`
Now create a pairing code:

```bash
codex remote-control pair
```

It prints `Pairing code:` and a short code, valid for a few minutes. In the
ChatGPT app on your phone, signed in to the same account and workspace, open
**Codex** (**Remote** in some versions), start adding a computer, and choose
to pair manually instead of scanning a QR code. Enter the code. The VM
appears as `my-codex-rc`. Pair each phone once; the pairing is saved on the
VM's disk.

> [!NOTE]
> If your ChatGPT account belongs to a workspace, its admin may have to
> allow Remote Control before pairing works.

## Start a chat from your phone

In the ChatGPT app, open `my-codex-rc`, choose the `~/project` folder and give
Codex a task. For example:

> Build a tiny website for a sandwich critic with strong opinions, and serve it on port 8000.

Codex works on the VM; you approve commands and read the diff on your phone,
and lock it whenever you like. Open `https://my-codex-rc.exe.xyz/` to see what
it built: it's private to you by default ([HTTPS proxy](/docs/proxy)).

- **Bring your code:** [connect a GitHub repo](/docs/integrations-github)
  to the VM, so it can clone and push with no token on the VM. On your
  computer, `ssh exe.dev integrations add github --name myapp --repository
  you/myapp --attach vm:my-codex-rc`; then, on the VM,
  `git clone https://github.int.exe.xyz/you/myapp.git ~/myapp`, and pick
  `~/myapp` in the app.
- **At the keyboard:** `ssh my-codex-rc.exe.xyz`, then `codex` in your
  project folder. The [Codex page](/deploy/codex) has the terminal setup.
- **Another agent:** [Shelley](/docs/shelley/intro), exe.dev's own agent, is on the
  VM too, at `https://my-codex-rc.shelley.exe.xyz/` in your phone's browser.

<details class="dp-details">
<summary>Update, back up and stop</summary>

### Update

The daemon updates its own copy of Codex: it checks five minutes after it
starts and then hourly, and restarts with the new version, which can
interrupt a running turn. To update it now, or to see what it runs:

```bash
codex app-server daemon update
codex app-server daemon version
```

The `codex` command you type is the copy exe.dev installed;
`sudo exeuntu update codex` updates it. To stop automatic updates, put
`"updater": { "autoUpdateEnabled": false }` in
`~/.codex/app-server-daemon/settings.json` next to `remoteControlEnabled`
and run `systemctl --user restart codex-remote-control`.

### Back up

Your code belongs in Git: commit and push. `~/.codex` holds your chats,
the ChatGPT sign-in and the VM's remote-control registration. For a copy of
the whole VM, run `ssh exe.dev cp my-codex-rc my-codex-rc-backup` on your
computer. The copy carries your ChatGPT sign-in, so delete it when you no
longer need it, and don't run remote control on both at once.

### Stop or unpair

Remove the device in the ChatGPT app to unpair a phone. To take the VM off
remote control, run `codex app-server daemon disable-remote-control` on it;
`codex logout` also signs Codex out of ChatGPT.

</details>

## Troubleshooting

- **`Remote control is enabled on my-codex-rc but the connection is
  errored.`** Codex isn't signed in to ChatGPT. `codex login status` says
  `Not logged in` or that it uses an API key. Sign in with
  `codex login --device-auth`, then restart the service.
- **`remote control pairing is unavailable until enrollment completes`.**
  Same cause: the VM hasn't registered with OpenAI's relay yet. Fix the
  sign-in, run `codex remote-control start`, then pair.
- **`timed out waiting for remoteControl/pairing/start response`.** Run
  `codex app-server daemon restart`, then pair again.
- **The device code is rejected.** Device code login is off in your
  ChatGPT security settings or workspace permissions.
- **The VM doesn't show up on your phone.** The phone must use the same
  ChatGPT account and workspace as `codex login status` on the VM. Update
  the ChatGPT app and pair again.

To dig further, on the VM: `codex doctor` checks the install and sign-in,
`journalctl --user -u codex-remote-control` shows the service, and
`~/.codex/app-server-daemon/daemon.stderr.log` is the daemon's log.

## Frequently asked questions

### Can Codex on the VM use exe.dev's LLM integration instead of my ChatGPT plan?

Remote control needs a ChatGPT sign-in on the VM: Codex refuses to connect to the relay with an API key, and exe.dev's ChatGPT integration can't stand in for it, because the relay connection is made with the login stored in `~/.codex`. This page uses your ChatGPT plan for the model too, which is what OpenAI supports. For ChatGPT-free Codex on a VM, use [the Codex page](/deploy/codex).

### Does this need the ChatGPT desktop app?

No. OpenAI's remote-connections guide describes pairing from the desktop app on macOS or Windows, but Codex CLI has its own, experimental pairing command, `codex remote-control pair`, which works on Linux with nothing else installed. Once paired, the VM shows up in the ChatGPT app on your phone, and on desktops that offer **Control other devices**.

### Who can control the VM?

Devices you pair while signed in to the same ChatGPT account and workspace as the VM. The VM makes an outbound connection to OpenAI's relay, so nothing on it listens to the internet. Anyone who can sign in to that ChatGPT account and pair a device can run commands on the VM, so keep multi-factor authentication on.

### Does it keep working when my laptop is closed?

Yes. Codex runs on the VM, not your laptop, and the service starts it again after a reboot. A VM restart interrupts a turn that's running; the chat itself is saved in `~/.codex`.

### How much does it cost?

Codex is open source. Model usage counts against your ChatGPT plan's Codex limits, and the VM is part of your exe.dev plan.

### Why put the daemon on a VM at all?

Since Codex CLI 0.157.0 the daemon runs in the background by default and updates itself. Many people would rather it didn't on their laptop. On a VM of its own it can stay on, and whatever Codex does happens on a machine you can copy or throw away.


## Related

- [Run Codex on a remote server](https://exe.dev/deploy/codex.md): A computer for Codex. An early night for your laptop.
- [Run T3 Code on a remote server](https://exe.dev/deploy/t3code.md): Your coding agents on an always-on VM, steered from your phone.
- [Run Claude Code on a remote server](https://exe.dev/deploy/claude-code.md): A computer for Claude. A breather for your laptop.
- [Give any agent a sandbox over MCP](https://exe.dev/deploy/exe-mcp.md): One URL gives your agent real VMs to run code on, host apps from, and hand work to.
- [Host OpenClaw](https://exe.dev/deploy/openclaw.md): An AI sidekick with its own computer. Your laptop can take a nap.
- [Run the Pi coding agent on a remote server](https://exe.dev/deploy/pi.md): An agent that doesn't ask first, on a computer that can take it.
