---
title: "Run Codex on a remote server"
description: "Codex is already installed on exe.dev. One setup command, a Git project, and a coding session that keeps going when you close your laptop."
url: https://exe-staging.dev/deploy/codex
category: "AI agents"
updated: 2026-10-17
---

# Run Codex on a remote server

A computer for Codex. An early night for your laptop.

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

## What you get

- Codex connected to a model, with no API key or sign-in
- A Git repository at `~/project` on persistent disk
- A `codex` tmux session that survives disconnects

Running on the VM:

- **Codex**: preinstalled; connected to exe.dev's LLM integration, data in `~/.codex`
- **Your project**: a Git repository, data in `~/project`
- **tmux**: keeps your terminal session running when you disconnect

How it is reached:

- ssh my-codex.exe.xyz (private): your terminal

## Deploy with Shelley

Open https://exe-staging.dev/new?prompt=Set%20up%20Codex%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe-staging.dev%2Fdeploy%2Fcodex.md%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-codex.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-codex.%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-%20Codex%20connected%20to%20a%20model%2C%20with%20no%20API%20key%20or%20sign-in%0A-%20A%20Git%20repository%20at%20%60~%2Fproject%60%20on%20persistent%20disk%0A-%20A%20%60codex%60%20tmux%20session%20that%20survives%20disconnects%0A%0AUse%20the%20preinstalled%20Codex.%20Run%20the%20VM-side%20setup%20in%20%22Start%20coding%22.%0ACreate%20tmux%20detached%20%28%60tmux%20new%20-d%20-s%20codex%20-c%20~%2Fproject%60%29%20rather%20than%0Aattaching.%20Reuse%20the%20session%20if%20it%20already%20exists.%20Do%20not%20launch%0Ainteractive%20Codex.%20If%20%60exeuntu%20configure%20codex%60%20reports%20%60existing%20user%0Aconfig%60%2C%20leave%20%60~%2F.codex%2Fconfig.toml%60%20alone%20and%20do%20not%20sign%20in%20or%20out%20of%0AChatGPT%3B%20ask%20the%20owner%20if%20this%20prevents%20setup.%20Verify%20from%20~%2Fproject%20with%0A%60codex%20exec%20-m%20gpt-6-luna%20%22Reply%20with%20exactly%3A%20OK%22%20%3C%2Fdev%2Fnull%60%20and%20check%0A%60tmux%20has-session%20-t%20codex%60.%20Skip%20the%20later%20optional%20instructions%20and%20FAQ.%0AFinish%20with%20the%20SSH%20command%20from%20%22Take%20a%20break%22%2C%20using%20this%20VM%27s%20name%2C%0Aand%20tell%20the%20owner%20to%20run%20%60codex%60%20inside%20it.%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-staging.dev/deploy/codex/prompt.txt | ssh exe.dev new --prompt=/dev/stdin
```

Or follow the steps below by hand.

Codex, OpenAI's coding agent, already ships with exeuntu, exe.dev's default
VM image. Hand it a VM of its own and let it build, run and break things
somewhere that isn't your laptop.

This setup uses exe.dev's [LLM integration](/docs/integrations-llm): no API key
to paste, no ChatGPT sign-in, and model usage billed to your exe.dev account.

## Start coding

On your computer, create a VM and connect. Pick any free name; 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
ssh my-codex.exe.xyz
```

On the VM, connect Codex to the LLM integration, make a project folder, and
open a tmux session. The project is a Git repository, so you can review and
undo whatever Codex changes:

```bash
exeuntu configure codex
git init ~/project
tmux new -A -s codex -c ~/project
```

Inside that session, start Codex:

```bash
codex
```

The first time, Codex asks whether to trust the project folder. Choose
**Trust and continue**, then give it a small task. For example:

> Build a tiny website for a sandwich critic with strong opinions.

That's the setup. Your files live in `~/project`.

## Take a break

Press **Ctrl-b**, then **d** to detach. Codex keeps working on the VM when
you disconnect. On your computer, use this command to hop back in:

```bash
ssh -t my-codex.exe.xyz 'tmux new -A -s codex -c ~/project'
```

A VM restart ends the running session, but not your saved work. Reconnect
and run `codex resume --last` from your project's folder on the VM to pick up
its last conversation.

## Loosen the leash

Out of the box, Codex edits files in your project freely but asks before it
reaches the internet or touches anything outside the folder. On a laptop,
that's a sensible default. On a VM you can copy and throw away, you may
prefer fewer questions: type `/permissions` in Codex and choose **Full
Access**. It can then install packages, start servers and use anything this
VM can reach, including [integrations](/docs/integrations) you've attached.

> [!TIP]
> Before a big unattended job, take a copy of the VM with
> `ssh exe.dev cp my-codex my-codex-backup` on your computer. If the job goes
> sideways, carry on from the copy.

## Make yourself at home

- **Pick a model:** type `/model` in Codex, or start it with
  `codex -m gpt-6-luna` for quick, cheap work. exe.dev keeps a
  [list of available models and prices](/llm-gateway-models).
- **Bring your code:** [connect a GitHub repo](/docs/integrations-github),
  clone it onto the VM, and run `codex` from its directory. Use that folder
  instead of `~/project` in the commands above.
- **Peek at your app:** ask Codex to serve it on `0.0.0.0:8000`, then open
  `https://my-codex.exe.xyz/`. It's private by default.
  [More about previews](/docs/proxy).
- **Script it:** `codex exec "Summarize the TODOs in this repo"` runs one
  task without the interactive screen and prints the answer. Add
  `--sandbox workspace-write` to let it edit files.

For Codex's own features, head to [OpenAI's Codex CLI docs](https://learn.chatgpt.com/docs/codex/cli).

## Frequently asked questions

### Can I use my ChatGPT plan instead?

Yes, two ways. Either way, first turn on device code login in your ChatGPT security settings. To keep your ChatGPT login off the VM, [connect your ChatGPT account to exe.dev](/docs/integrations-llm#connect-a-chatgpt-account) and attach the LLM integration that uses it to this VM. Then, in `~/.codex/config.toml`, change `base_url` to that integration's address, such as `https://chatgpt-llm.int.exe.xyz/v1`. Or sign in on the VM itself: delete the `model_provider = "exe-llm"` line from that file, run `codex login --device-auth`, and open the link on your computer.

### What if the setup command doesn't work?

If it says `existing user config`, it has left your `~/.codex/config.toml` alone. That's normal once you've used Codex, which saves its own settings there. Run `codex doctor` on the VM to see which provider and model Codex will use. When you add top-level settings to that file, put them above the `[model_providers."exe-llm"]` line, or TOML files them under that section. The [LLM integration docs](/docs/integrations-llm#use-with-codex) show the full configuration.

### How do I update Codex?

Codex shows a banner when there's a new release. On the VM, run `sudo exeuntu update codex`, then reopen your last chat with `codex resume --last`. See [updating coding agents](/docs/upgrade-codex) to pin a version.

### How do I back up my work?

Commit and push your code. For a copy of the whole VM, run `ssh exe.dev cp my-codex my-codex-backup` on your computer (choose a free backup name). To use that copy, connect with `ssh my-codex-backup.exe.xyz`; your files and Codex history are there. Reattach any [VM-specific integrations](/docs/integrations-attach).


## Related

- [Run OpenCode on a remote server](https://exe-staging.dev/deploy/opencode.md): Every model, one VM, and an agent that works while your laptop sleeps.
- [Run Claude Code on a remote server](https://exe-staging.dev/deploy/claude-code.md): A computer for Claude. A breather for your laptop.
- [VS Code in your browser, with code-server](https://exe-staging.dev/deploy/code-server.md): Your editor in a tab. Your projects right where you left them.
- [Host OpenClaw](https://exe-staging.dev/deploy/openclaw.md): An AI sidekick with its own computer. Your laptop can take a nap.
- [Self-host Hermes Agent](https://exe-staging.dev/deploy/hermes-agent.md): An agent that remembers you, on a computer that never sleeps.
- [Host a Pi Durable agent](https://exe-staging.dev/deploy/pi-durable.md): An agent that picks up where it left off, even after kill -9.
