Codex on a VPS
Set up Codex on a remote Linux server: sign in without a browser on the machine, keep the session alive after you disconnect, and run it without prompts. Or use an EnvHaven workspace, a server with all of that done.
Updated November 23, 2026 · Checked against Codex 0.157.1 in EnvHaven v1.9.0
Two things trip people up when Codex moves to a remote server: signing in on a machine with no browser, and keeping the session alive after the SSH connection drops. An EnvHaven workspace is a remote server with both handled. That route comes first; the same setup on a VPS you run yourself follows.
The ready-made server: an EnvHaven workspace
- Create a workspace in any of 11 regions and open it in a browser. It is a Linux server of its own.
- Tap Launch, choose Codex and tap Sign in: it runs
codex login --device-auth, which shows a one-time code to approve in ChatGPT (turn on device code sign-in in ChatGPT’s security settings first). - Start it with one tap: signed in, Codex gets a green dot in the Launch menu and an icon in the workspace’s top bar. Support is built in (0.157.1), so there is nothing to install or update.
- Give it a task. The image writes both settings into
~/.codex/config.toml, socodexstarts without approvals. - Disconnect whenever you like. The terminal session stays on the server, and you can come back to it from the browser, from any SSH client, or from your own editor through Haven CLI.
Plans start at $15 a month, billed annually, with an HTTPS preview URL for what Codex builds, Docker on Plus and Pro, and no idle shutdown.
On a VPS you set up yourself
Create the server. Any Linux VPS works (Ubuntu or Debian is the common choice). Log in over SSH and add a regular user with sudo, then run the agent as that user: full-access modes are meant for an unprivileged account, and some refuse root.
Install Codex.
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Sign in without a browser on the server.
- Run
codex loginand sign in with ChatGPT. On a machine without a browser,codex login --device-authprints a code to approve on any device (turn on device code login in ChatGPT’s security settings first). - Or use an API key:
printenv OPENAI_API_KEY | codex login --with-api-key, orCODEX_API_KEYfor non-interactive runs. Codex does not readOPENAI_API_KEYby itself.
Keep it running after you disconnect. Start it inside tmux:
tmux new -s codex
codex --dangerously-bypass-approvals-and-sandbox
# detach: Ctrl+B, then D. Come back with: tmux attach -t codex
Leave it on. Make sure the server has no idle shutdown, and keep Codex updated yourself.
For work at set times rather than continuously, cron on that server can call it headless:
crontab -e
# every day at 07:00
0 7 * * * cd ~/my-project && codex exec "Summarize yesterday's commits into CHANGELOG.md"
What a self-managed server leaves to you is the rest: HTTPS and a public address for what Codex builds, updates for every tool, and the machine itself. The cost comparison puts the options side by side.