Skip to content

Host-managed login

Sign in to ChatGPT once on the host for Codex, Pi or OpenCode, install the pinned clients on Linux, and keep logins renewing.

Updated

Codex, Pi and OpenCode can use a ChatGPT subscription. With a host-managed login, you sign in once on the host with the vendor’s own client, and abx hands each box a masked handle instead of the real token. This page covers the setup, the Linux install rules for the clients, and how renewal behaves when you log out of an SSH session.

Host-managed logins work on macOS and Linux. Each client owns its own login: a ChatGPT grant obtained through Codex is not shared with Pi or OpenCode.

Requirements

Install the native client on the host at the exact version the adapter pins. abx compares the version exactly.

Client Pinned version --version output
Codex 0.173.0 codex-cli 0.173.0
Pi 1.7.0 1.7.0
OpenCode 2.4.3 2.4.3

OpenCode host login also requires /usr/bin/sqlite3.

abx looks for the client in fixed directories, in this order, and never consults PATH:

  • macOS: /usr/bin, /bin, /opt/homebrew/bin, /usr/local/bin, ~/.local/bin, ~/Library/pnpm/bin.
  • Linux: /usr/bin, /bin, /usr/local/bin, ~/.local/bin.

The login is stored under $ABX_HOME/profiles/host/<agent>/<profile>/, outside any workspace or box directory.

Sign in

Run the login from a terminal. The profile name defaults to default.

abx auth login codex --provider openai --mode device --profile work
abx auth verify codex
abx codex first-task
abx codex second-task

Pi and OpenCode use --mode chatgpt:

abx auth login pi --provider openai --mode chatgpt --profile work
abx auth login opencode --provider openai --mode chatgpt --profile work

abx auth login always uses masked access, so --access accepts only masked. To select a profile that already exists, use abx auth set with --profile:

abx auth set codex --provider openai --mode device --profile work

Several boxes can share one profile. Verify the agent once with abx auth verify before launching boxes, because masked credentials are released only after verification passes.

Refresh and revoke

Running boxes with renewable credentials get updated tokens from a detached host process. Two commands act on one box:

abx auth refresh first-task codex
abx auth revoke first-task codex

refresh forces a renewal. revoke removes that box’s binding and leaves other boxes untouched. The agent argument is optional. OpenCode renews close to its native expiry, so a verification can wait for that window.

Linux client installation

On Linux, abx validates the client launcher, its package tree, ELF binaries and the required system helpers (/usr/bin/env, /usr/bin/node, /usr/bin/sqlite3) before it runs even --version. Install each client into ~/.local or a protected system path such as /usr/local, with directory modes such as 0755 or 0700. Trust roots, ownership and permission rules are described in Linux hosts.

npm layout: npm-installed Codex and Pi must use the exact #!/usr/bin/env node shebang. They need a regular package.json file at the package root (symlinks are refused) and no node_modules directory above the install prefix, such as ~/node_modules or ~/.local/node_modules.

No version managers: installs under nvm, asdf, nodenv, volta, fnm, mise or n/versions are rejected.

Client Accepted Linux layout Required system helpers
Codex npm package @openai/codex@0.173.0 (.../node_modules/@openai/codex/bin/codex.js), or a static or glibc Linux ELF64 codex Native ELF /usr/bin/node for the npm launcher (a standalone ELF may use /usr/bin/node, /bin/node or /usr/local/bin/node), and /usr/bin/env
Pi npm package @earendil-works/pi-coding-agent@1.7.0 (.../node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js), or a native Linux ELF64 under ~/.pi or ~/.local Native ELF /usr/bin/node and /usr/bin/env for the npm install; none for a standalone ELF
OpenCode Native Linux ELF64 binary only. npm wrappers and shell shims are refused. Root-owned native ELF /usr/bin/sqlite3

These per-user installs use isolated prefixes under ~/.local and no npm -g:

umask 022
mkdir -p ~/.local/bin ~/.local/share

# Codex 0.173.0 (needs a system /usr/bin/node, for example the distro nodejs package)
npm install --prefix ~/.local/share/codex --no-audit --no-fund @openai/codex@0.173.0
ln -sfn ../share/codex/node_modules/@openai/codex/bin/codex.js ~/.local/bin/codex

# Pi 1.7.0 (the npm layout also needs a system /usr/bin/node)
npm install --prefix ~/.local/share/pi --no-audit --no-fund @earendil-works/pi-coding-agent@1.7.0
ln -sfn ../share/pi/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js ~/.local/bin/pi

# OpenCode 2.4.3 (native ELF64 tarball; needs /usr/bin/sqlite3)
case "$(uname -m)" in
  x86_64)
    OPENCODE_ASSET="opencode-linux-x64.tar.gz"
    OPENCODE_SHA="1bf509e8055b00693bf14d1623fd74712a7c6c107565e2acf38044944e7535d7"
    ;;
  aarch64)
    OPENCODE_ASSET="opencode-linux-arm64.tar.gz"
    OPENCODE_SHA="6c7390a391917b0c241a1530b2efb40ac7255d9a2c49dd363f5c7dc8178adaeb"
    ;;
  *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
curl -fsSLO "https://opencode.ai/files/bin/2.4.3/${OPENCODE_ASSET}"
printf '%s  %s\n' "$OPENCODE_SHA" "$OPENCODE_ASSET" | sha256sum -c -
tar -xzf "$OPENCODE_ASSET" -C ~/.local/bin opencode
chmod 0755 ~/.local/bin/opencode

Renewal after SSH logout on Linux

abx starts a detached worker process to renew host logins and installs no service. Logging out of an SSH session can end that worker. After you reconnect, run this from the box’s workspace:

abx auth status --box NAME

Add --json for the worker state, the last credential check and any known expiry. The report shows whether the worker is running. A running worker holds the box’s private renewal lock (mode 0600). A successful delivery records when smolvm accepted the update. The ordinary abx auth status <agent> report describes configuration and template verification only.

The worker polls once a minute for host logins and for masked pass:// bindings. Detached pass renewal uses the account’s default password store and GnuPG configuration. A box started with PASSWORD_STORE_DIR, GNUPGHOME or XDG_CONFIG_HOME set reports session-store; run abx auth refresh NAME AGENT in that environment. A pass box that was already running at upgrade needs a foreground refresh or a restart to establish its store. Keep the selected entry accessible without an interactive pinentry.

If the worker loses provider access, or cannot renew an expired host grant, it records the reason and stops the affected Linux box. Restore provider access and reopen the box. If logout kills the worker while the VM keeps running, status reports not-running. Stop the box if its last credential should no longer be usable, then reopen it from a session that has provider access. An expired or rejected upstream credential can also require signing in again.

On a systemd host, the last logout can remove /run/user/<uid>, the user bus and the agent sockets. If your provider needs the user manager between sessions, you or an administrator can run loginctl enable-linger USER where local policy permits it. A locked GPG agent can still need interactive access. With KillUserProcesses=yes, logind can end processes in the launching session’s scope even with lingering enabled; Ubuntu defaults to KillUserProcesses=no. See systemd login sessions and loginctl.

Alternative: Codex device login in the guest

Codex openai/device also exists as a login the guest keeps, with global or local access. Use it when you do not want the host to hold the grant. With abx auth set and no --profile, you must pick the route with --access.

You run the official device flow inside a box with abx codex <box> -- login --device-auth and finish consent in your browser. Codex then stores the login in ~/.codex/auth.json in the guest. The account or workspace may need device authentication enabled in OpenAI’s settings. The steps for shared (global) and single-box (local) logins are on the Codex agent page. See also Codex authentication.

Type to search…

↑↓ navigate↵ selectEsc close