Back to all articles
TutorialDecember 2, 2026·10 min read

How to Use Codex on an SSH Host and Keep Project Context There (2026)

Your project doesn't live on your laptop. It lives on a dev box in the office, a big cloud machine with a GPU, or a remote server with the database you can't run locally. You already reach it over SSH every day. Now you want Codex to work there too: read the real files, run the real tests, and use the tools installed on that machine, without copying the project to your laptop first.

The short answer: the ChatGPT desktop app can add projects from an SSH host. OpenAI's documentation says: "In the ChatGPT desktop app, add remote projects from an SSH host and run chats against the remote filesystem and shell." Codex reads files, runs commands, and writes changes on the remote host. That also means the project context Codex uses, such as AGENTS.md, skills, MCP servers, and configuration, comes from the remote host, not from your laptop.

This guide covers what an SSH host connection is, what you need, how to set it up, what comes from the connected host, how to keep project context on it, how to move a chat between your laptop and the host, and how to keep the connection safe.

What an SSH host connection is

OpenAI's remote connections page describes several ways to reach work on another machine. One is controlling your desktop from your phone. Another is connecting the desktop app to a project on an SSH host. This guide is about the second.

OpenAI's page suggests an SSH host "when the project already lives in a remote environment." It describes what happens: ChatGPT "works in the remote environment with its dependencies, security policies, and compute resources."

The page states the core behavior plainly: "Remote project chats run commands, read files, and write changes on the remote host."

So your laptop runs the desktop app, and the remote machine does the work. You see the chat, the diffs, and the results on your laptop, but the files and the shell are on the host.

What you need

Before you start, make sure of four things:

  1. The ChatGPT desktop app on the machine you're working from.
  2. SSH access to the host from that machine, with the host in your SSH config.
  3. Codex installed and authenticated on the remote host, with the codex command on the remote user's PATH.
  4. A project folder on the host that Codex should work in.

OpenAI's page explains why the third item matters: "The app starts the remote Codex app server through SSH, using the remote user's login shell." If codex isn't available in that shell, the connection can't start.

How to connect Codex to an SSH host

OpenAI's setup has four steps.

Step 1: Add the host to your SSH config. OpenAI's example looks like this:

Host devbox
  HostName devbox.example.com
  User you
  IdentityFile ~/.ssh/id_ed25519

OpenAI's page explains how Codex uses it: "Codex reads concrete host aliases from ~/.ssh/config, resolves them with OpenSSH, and ignores pattern-only hosts." So a host entry with a specific name works, while a wildcard pattern on its own won't appear.

Step 2: Confirm you can connect. From the machine running the app, connect to the host with SSH using the alias you set. If that fails, fix it before going further.

Step 3: Install and authenticate Codex on the remote host. Make sure the codex command is on the remote host's PATH in the remote user's login shell.

Step 4: Add the host in the app. OpenAI's instructions: "In the app, open Settings > Connections, add or enable the SSH host, then choose a remote project folder."

After that, you can start chats in that remote project.

What comes from the connected host

This is the part that affects context the most. OpenAI's page has a section on it. Its list says:

  • "Repository files and local documents come from the connected host."
  • "Shell commands run on that host or remote environment."
  • "MCP servers, skills, browser access, and Computer Use come from that host's configuration."
  • "Signed-in websites and desktop apps are available only when the host can access them."
  • "The sandboxing settings, security controls, and action approvals still apply to the connected session."

The general rule is in the page's introduction: "Remote access uses the connected host's projects, chats, files, credentials, permissions, plugins, Computer Use, browser setup, and local tools."

In practice, that means your laptop's setup doesn't follow you. If you configured an MCP server on your laptop, Codex on the SSH host won't have it unless it's configured on the host. If you wrote a skill on your laptop, it needs to be on the host too.

SSH host, laptop, or always-on computer

OpenAI's page compares three kinds of hosts, and the choice affects where your context lives.

Your laptop or desktop gives remote access to "the same projects, chats, credentials, plugins, and local setup you already use." But if it sleeps, loses network access, or closes the app, remote access stops.

A dedicated always-on computer suits longer-running work. OpenAI's advice for it applies to SSH hosts too: "Install the projects, credentials, MCP servers, skills, and tools ChatGPT or Codex should use on that machine."

An SSH host or managed remote development environment fits when the project already lives there. The project's dependencies, security policies, and compute come with it.

Whichever you choose, the context Codex uses is the context on that machine.

How to keep project context on the host

Codex reads project guidance from the project itself. OpenAI's projects documentation says: "Keep durable project guidance in AGENTS.md or checked-in documentation so it is available to future chats."

On an SSH host, that's good news. If AGENTS.md is in the repository on the host, Codex finds it there. OpenAI's projects page explains which folder matters in the desktop app: the primary folder is the default "for Git operations and automatic discovery of AGENTS.md, skills, and config.toml." Secondary folders are available for search and editing, but Codex "doesn't automatically discover those project files from secondary folders."

Here's what to check on the host:

Project instructions. Put AGENTS.md in the repository on the host, in the folder you chose as the project. If you keep a different version on your laptop, they'll drift apart.

Skills. Install the skills you rely on where the host's Codex can find them.

MCP servers. Configure them on the host. For how Codex reads MCP servers from its configuration file, see how to add an MCP server to Codex.

Credentials. The host's credentials are the ones Codex uses. Make sure the remote user can reach the services the project needs, and nothing more.

Memories. OpenAI's IDE guidance mentions using memories "from the connected Codex host, where available". Like the rest, they belong to the host.

Hand off a chat between your laptop and the host

Sometimes you start work locally and want to continue on the host, or the other way round. OpenAI calls this handoff: "Handoff moves an existing chat and its Git state between your local computer and a connected remote host."

Before you hand off, OpenAI's page says to connect the destination host and "save a project for the same Git repository on that host." If the project is a subdirectory of the repository, save the same subdirectory on both hosts. Codex only shows destinations with a matching saved project.

To hand off a chat, OpenAI's steps are:

  1. Open the chat in the desktop app.
  2. In the chat footer, select the current run location, then select the destination host. Select This computer to hand a remote chat back.
  3. Review the destination and branch, then select Hand off.

OpenAI describes what happens next: "Codex creates or reuses a worktree on the destination host, transfers the chat and Git state, and switches the chat to that host." If the chat is running, handoff interrupts the current response first.

Two limits apply. OpenAI's page says Codex can't hand off the chat making the request, and "handoff to a Codex cloud environment isn't supported."

Handoff moves the chat and Git state. It doesn't move the host's configuration. Skills, MCP servers, and credentials on the destination host still come from that host.

Keep the connection safe

An SSH host gives Codex a real shell on a real machine, so the usual rules apply. OpenAI's page says: "Keep the remote host configured with the same security expectations you use for normal SSH access: trusted keys, least-privilege accounts, and no unauthenticated public listeners."

On network exposure, OpenAI is direct: "Don't expose app-server transports directly on a shared or public network." To reach a machine outside your network, it recommends "a VPN or mesh networking tool instead of exposing the app server directly to the internet."

What people try first

Expecting laptop skills and MCP servers to work on the host. They come from the host's configuration.

Using a wildcard entry in SSH config. Codex ignores pattern-only hosts.

Installing Codex only on the laptop. The app starts the remote Codex app server through SSH, so codex must be on the host.

Keeping AGENTS.md only on the laptop. Codex on the host reads the host's project files.

Handing off without a matching project. Codex only shows destinations with a matching saved project.

The Fix: Set up the host so Codex has what it needs

Step 1: Pick the primary project folder

Choose the folder on the host where AGENTS.md, skills, and config.toml should be discovered.

Step 2: Put project guidance in the repository

Write AGENTS.md and any checked-in documentation in the repository on the host.

Step 3: Mirror the tools you rely on

Install the skills and configure the MCP servers Codex should use on the host.

Step 4: Write down what spans machines

Keep the decisions and background that apply wherever you work, such as why the project uses this host, in a short note of your own.

Setting this up in MemoryLake

The host's repository holds the code and its guidance. But some context spans machines and tools: why a migration is paused, which environment is safe to test against, what a customer asked for. That context is useful in other assistants too.

MemoryLake is a memory layer for that kind of project context, kept in one place you maintain and available to the assistants you connect, such as ChatGPT, Claude Code, and Codex.

You write the entries yourself. Nothing is read out of, written to, or deleted from your SSH host, your repository, your AGENTS.md, your Codex configuration, Codex memories, or any vendor's store. Codex on an SSH host works the way OpenAI describes it.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with the note from Step 4 of the fix: the decisions and background that apply on every machine.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect Codex, ChatGPT, Claude Code, and the other assistants you use, so the same context is there in each.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is less drift. Context that isn't tied to one machine stays in one place.

The second is easier handoffs. When you move between your laptop and the host, the background you rely on doesn't depend on which machine you're on.

The third is reach. The same context is available in the other assistants you use.

Best practices for Codex on an SSH host

Use a concrete host alias. Pattern-only entries are ignored.

Check the remote login shell. codex must be on its PATH.

Keep AGENTS.md in the host's repository. That's where Codex reads it.

Configure tools on the host. MCP servers and skills come from the host's configuration.

Save matching projects before handoff. Same repository, same subdirectory.

Use least-privilege accounts. Codex acts with the remote user's access.

Don't expose the app server publicly. Use a VPN or mesh networking tool.

Conclusion

The ChatGPT desktop app can connect Codex to a project on an SSH host. Add the host to your SSH config, make sure you can connect, install and authenticate Codex on the host, then add the host in Settings, then Connections, and choose a remote project folder. From then on, remote project chats read files, run commands, and write changes on the host.

Everything Codex uses comes from the host: repository files, shell, MCP servers, skills, credentials, and memories where available. Keep AGENTS.md in the host's repository, set up tools there, save matching projects before handoff, and keep the host as secure as any SSH server.

Frequently asked questions

Can Codex work on a remote server over SSH?

Yes. In the ChatGPT desktop app, you can add remote projects from an SSH host and run chats against the remote filesystem and shell.

Does Codex need to be installed on the SSH host?

Yes. The app starts the remote Codex app server through SSH, so codex must be on the remote user's PATH.

Why doesn't my SSH host appear in Codex?

Codex reads concrete host aliases from your SSH config and ignores pattern-only hosts. Check that you can connect with SSH first.

Does Codex on the SSH host use my laptop's skills and MCP servers?

No. OpenAI says MCP servers, skills, browser access, and Computer Use come from the host's configuration.

Where should AGENTS.md go when using an SSH host?

In the repository on the host, in the project's primary folder, where Codex discovers it.

Can I move a chat from my laptop to the SSH host?

Yes, with handoff, after saving a project for the same Git repository on the host.

Can I hand off a chat to Codex Cloud?

No. OpenAI says handoff to a Codex cloud environment isn't supported.