gilvt
Remote development guide

How to run Claude Code and Codex over SSH

Putting the agent next to the code — on a dev box, a GPU server or a build machine — is often faster and safer than syncing everything to your laptop. The hard part is not starting it; it is noticing when a remote session stops to ask you something.

Short version: install and sign in to claude or codex on the remote host, start it from an SSH session in the project directory, and decide up front whether the process must survive a dropped connection (use tmux) or whether resuming the conversation is enough (claude --resume, codex resume). Then make the remote agents' state visible on your Mac, so you are not polling SSH tabs.

Why run the agent on the remote machine

Your Mac stays the place where you read, decide and approve; the server does the work.

1. Install and sign in on the remote host

Claude Code and the Codex CLI both run on Linux and macOS. Install them on the remote host the way their documentation describes, then run them once in an SSH session to sign in. On a headless server the sign-in flow gives you a URL to open in your local browser. Do this once per host and user; later sessions reuse the stored credentials.

ssh devbox
cd ~/src/payments-api
claude          # or: codex

Start the agent from the project directory: both CLIs scope their session history and project settings to the directory they were started in.

2. Decide what should survive a dropped connection

When an SSH connection drops, the processes in that login session normally end with it, including an agent in the middle of a turn. There are two different ways to recover, and they solve different problems:

tmux on the remote hostAgent resume
What survivesThe running process: the agent keeps working while you are disconnectedThe conversation: history, context and the session's identity
How you get backssh devbox, then tmux attachclaude --resume or claude --continue; codex resume
CostAnother layer between you and the agent's TUI; mouse, scrollback and key handling go through tmuxA turn that was cut off has to be asked for again

For short, interactive sessions on a stable connection, resume is usually enough. For long autonomous turns, or a flaky network, run the agent inside tmux.

3. Keep the connection cheap to reopen

If you open several panes to the same host, let them share one SSH connection so new panes start instantly and authenticate once:

# ~/.ssh/config
Host devbox
  HostName devbox.example.com
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m
  ServerAliveInterval 30

ServerAliveInterval also makes a dead connection fail fast instead of hanging.

4. Don't lose track of remote sessions

The real cost of remote agents is attention. A local agent can at least ring a bell; a remote one sits in an SSH tab waiting for approval, and you find out when you happen to look. With two or three hosts and several sessions each, checking every tab becomes the job.

What helps is getting the same signals you would have locally — needs approval, asking a question, failed, done — on your Mac, with a way to jump straight to the pane. You can build part of this with agent hooks that send a message back to your Mac (see getting notified when Claude Code needs you), but the hook runs on the server, so it needs a path back to your Mac.

How gilvt handles SSH

In gilvt you keep typing plain ssh. For an interactive login to a Linux host (x86_64 or aarch64) or an Apple Silicon Mac, gilvt treats the pane as remote: the pane and tab show the host, the remote shell gets gilvt's shell integration, and the remote directory is tracked. ssh host command, scp and git push run unchanged.

  1. The first time you connect to a host, gilvt asks whether to install a small helper there (~/.gilvt-server). Y installs it, n skips it this time, N never asks again for that host. Without it, ssh logs in the plain way.
  2. Run claude or codex in the remote shell as usual. The session appears in gilvt's sidebar next to your local ones, with the same states, notifications, ⇧⌘J jump-to-approval and per-turn inspector timeline.
  3. Look at remote files from the remote shell: gilvt view, gilvt diff and ⌘-click on a path open the host's files in Quick Look, and the built-in editor writes changes back to the host.
  4. Resume later: remote sessions are in the session history (⇧⌘R), so you can resume one after the connection is gone.
gilvt's sidebar listing coding-agent sessions by state, with the ones that need you at the top.
Remote sessions are listed alongside local ones; the ones waiting for you rise to the top.

To skip gilvt's handling for one connection, run command ssh host or GILVT_SSH=0 ssh host. To remove the helper from a host: pkill -f '[.]gilvt-server/'; rm -rf ~/.gilvt-server.

Current limits

SSH support in gilvt is a preview. Be aware of what it does not do yet:

The full list is in the user guide's SSH section.

Try it: download gilvt (free, macOS 11 or later), open a pane, ssh to your dev box and start claude. The session shows up in the sidebar as soon as it starts.