Contents
Codex is OpenAI’s coding agent. Like Claude Code, it reads the project, edits files and runs commands, then shows you what changed. On a hosting account you can use it in two ways: run the CLI inside an SSH session, or drive it from the Codex app on your computer, which starts Codex on the server over SSH.
Before you start
- A plan with SSH and a key that signs in: Connect to your server over SSH.
- Node.js on the server for the npm install; Node.js 24 is a good choice.
- A ChatGPT account whose plan includes Codex, or an OpenAI API key.
- The project in Git, so you can review and undo every change.
Way 1: Codex CLI on the server
1. Install it in your home folder
ssh myhosting
npm install -g @openai/codex@latest --prefix ~/.local
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # once, if it isn't there yet
source ~/.bashrc
codex --version
Installing into ~/.local avoids EACCES errors, because hosting accounts can’t write to system folders. To update, run the same npm install command again. OpenAI’s documentation also lists a standalone installer; both give you the same codex command.
2. Sign in without a browser on the server
The default sign-in opens a browser on the same machine, which a server doesn’t have. Use device code login instead:
- In ChatGPT, open your security settings and enable device code login for Codex. In a workspace, an admin enables it in the workspace permissions.
- On the server, run:
codex login --device-auth - Open the address it prints on your computer or phone, enter the code and approve.
- Confirm the result:
codex login status
Prefer an API key? Feed it in without leaving it in your shell history:
read -rs OPENAI_API_KEY && export OPENAI_API_KEY # paste the key, press Enter
printenv OPENAI_API_KEY | codex login --with-api-key
unset OPENAI_API_KEY
Codex keeps the login in ~/.codex/auth.json. Treat that file like a password: never copy it into a project or commit it.
3. Add project instructions
cd ~/myapp
codex
Run /init in the first session. It creates AGENTS.md, where you keep the test command, the coding style and rules such as “this folder is the live site; never delete files in public_html/uploads”. Codex reads it at the start of each session.
4. Choose what Codex may do
Type /permissions to see and change what Codex may do on its own, from read-only to editing files and running commands. On a live site keep a mode that asks before running commands, and widen it only on a staging copy.
For scripts there’s a non-interactive mode:
codex exec "Run the test suite and summarize any failures"
Way 2: the Codex app over SSH
The Codex desktop app can work on a remote machine: it connects over SSH and starts Codex on the server through your login shell. That’s why the server still needs steps 1 and 2 of Way 1.
- On your computer, add a named host to
~/.ssh/config. The app reads concrete host names and ignores wildcard entries such asHost *:Host myhosting HostName your-host User myuser IdentityFile ~/.ssh/id_ed25519 - Check from a terminal:
ssh myhosting 'command -v codex'should print a path such as/home/myuser/.local/bin/codex. - In the app, open Settings > Connections, add or enable
myhosting, and choose the project folder on the server.
In VS Code you can get the same result with the Remote - SSH extension and OpenAI’s Codex extension installed on the SSH host.
Safety checklist
- Never paste passwords, tokens or customer data into prompts; keep secrets in
.envand environment variables. - Make sure
.gitignorelists.env, and keep secrets out ofAGENTS.md. - Commit before each task, read the diff and test before you deploy.
- Remember that the code and command output Codex reads are sent to OpenAI to generate answers; follow your data rules.
- Watch for instructions hidden in files or web pages the agent reads (prompt injection).
Troubleshooting
- The app connects, then drops within a second:
codexisn’t on thePATHof the server’s login shell. Ifssh myhosting 'command -v codex'prints nothing, add theexport PATH=...line to~/.bashrc, and to~/.bash_profileif that file exists. codex: command not foundright after installing: open a new SSH session or runsource ~/.bashrc.EACCESfrom npm: add--prefix ~/.local(npm EACCES).- Device code login is refused: it isn’t enabled in your ChatGPT security settings, or your workspace admin hasn’t allowed it.
- The app says you’re not signed in: it uses the server’s login, so run
codex login statuson the server and sign in there. - Commands fail with a sandbox error: Codex’s sandbox relies on features of the server’s operating system. Read the sandbox section of OpenAI’s Codex documentation before changing settings, and keep approvals on for a live site.
- Killed processes or
Resource temporarily unavailable: you reached the account’s memory or process limit; run fewer jobs at once.
On ArabyHost
Codex runs over SSH on the AI/Developer plans, with every account isolated in CloudLinux CageFS. Node.js 24 and Python 3.12 are on your PATH and npm install -g installs inside your account, so Codex works without root; the Connect Claude Code page in the Araby Panel covers Codex too and shows the host, user and port to use. There’s no root access or Docker, so system packages can’t be installed. Prefer Anthropic’s agent? See Claude Code on a server. Codex is an OpenAI product used with your own OpenAI account; ArabyHost has no partnership with OpenAI and never keeps your keys.
FAQ
Do I need a ChatGPT subscription for Codex?
Codex signs in with a ChatGPT account whose plan includes Codex, or with an OpenAI API key billed by usage. Check OpenAI's pages for which plans include it today.
What is AGENTS.md?
A Markdown file in the project root with instructions for Codex: how to run tests, the coding style and what not to touch. Codex reads it at the start of a session, and `/init` writes a first draft.
Is the Codex app the same as the Codex CLI?
They run the same agent. The CLI works in a terminal; the desktop app adds a visual interface and, through remote connections, starts Codex on the server over SSH, which is why the server needs the CLI installed.