Skip to content
ForgeVPS

Work with your VPS

Run Codex CLI on your VPS.

Install OpenAI Codex CLI on a VPS, sign in with device authentication, and work from a browser terminal. Includes phone access and session recovery.

Codex CLI can work with a project on your VPS while you access its terminal through ForgeVPS. The code stays on that server; you can return to the workspace from a different computer or your phone.

Prepare your workspace

You need a connected Ubuntu or Debian VPS, a working ForgeVPS terminal, and your own account access for the coding assistant. The VPS hosts the command-line tool and your files; model requests go to the assistant’s provider. ForgeVPS access does not include server hosting or AI usage.

If you still need a machine, start with the first VPS guide. For an existing connection, open Terminal and run whoami and pwd to check where commands will run. Terminal needs tmux on the VPS; enable Workspace tools where available or have it installed before continuing.

ForgeVPS currently uses root-backed access. Keep the assistant’s permission checks enabled, read its proposed commands, and use the practice directory below for your first task.

1. Install Codex CLI on the VPS

First check whether the command is already available:

codex --version

If it is missing, OpenAI’s CLI documentation provides this Linux installer:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

The command downloads and executes OpenAI’s installer on your server. Follow its output, open a new terminal if necessary, and check codex --version again. ForgeVPS’s Claude Code setup step does not install Codex.

2. Sign in from a remote terminal

For a ChatGPT account, use the device-login flow:

codex login --device-auth

Open the displayed link in your browser and enter the one-time code. Device login must be enabled in your account’s security settings or by your workspace administrator. OpenAI documents this headless sign-in method and alternatives on its authentication page.

Keep the code private. If your organization disables device login, follow its approved authentication method. Signing into ForgeVPS does not provide Codex access, and your OpenAI plan or API usage is separate.

3. Start Codex in a practice project

demo_dir=$(mktemp -d "$HOME/codex-vps-demo.XXXXXX")
cd "$demo_dir"
pwd
git init
codex

This creates a fresh directory and initializes Git there. Note the path printed by pwd. Review Codex’s trust and permission prompts; keep approval checks enabled for this first exercise.

Make a small file you can inspect

Give Codex this first task in your new practice directory:

Create an index.html file with a heading and a short paragraph about a VPS practice project. Use plain HTML and CSS. Do not install packages, start a server, or deploy anything. Explain the changes.

Review the requested actions. When the task finishes, open Files in ForgeVPS, navigate to the exact directory printed by pwd, and open index.html. Check its contents before making your own edit.

For an existing project, start with an explanation or a focused change and inspect the diff before committing. Follow the browser editor walkthrough to create, edit, and save files directly in Files. Creating this practice file does not publish a website.

ForgeVPS file browser and code editor showing demo project files
ForgeVPS editor preview with demo data. Use Files to inspect the actual files Codex creates in your practice folder.

Return from your phone or another browser

  1. Leave the terminal tab inside ForgeVPS open. Close the browser window or put the first device aside.
  2. Sign in to ForgeVPS from your phone’s browser.
  3. Choose the same machine and its existing terminal tab. Check the task’s latest output and any pending permission request.

ForgeVPS uses tmux sessions on the VPS, which ordinarily survive a disconnected browser. Closing a terminal tab inside ForgeVPS ends that session. A reboot, stopped process, or exhausted memory can also end a running task.

Phone access is useful for a short instruction or progress check. Use a larger screen for detailed code review. Keep login codes, account details, and private project files out of any screenshots you share.

If the Codex process has exited

Return to the same project directory and use codex resume to choose a saved conversation. Resuming a conversation does not restore a stopped build or other process. See the Codex CLI guide for the available session commands.

Troubleshooting

  • Command not found: read the installer’s result, verify its PATH instructions, and retry from a new shell.
  • Login opens a localhost address that fails: use device authentication on the VPS. The server and the browser on your phone have different localhost addresses.
  • Device authentication is unavailable: check the account or workspace setting. If --device-auth is unknown, check the installed CLI version against the official documentation.
  • Codex cannot perform an action: read the specific permission or environment error. Resolve the missing dependency or grant only the required permission; do not disable all checks to make the message disappear.
  • The terminal disappeared: check whether its tab was closed or the VPS restarted. Open a new terminal and return to your project; then try the saved-conversation picker.

For the equivalent Anthropic workflow, see Claude Code on a VPS. For manual edits, use the browser code editor alongside either assistant.