Skip to main content

How to Run Claude Code on a Remote Machine over SSH

Install Claude Code on the remote machine and run it there. Your computer only shows the session, so the code, the tools and the agent's commands all stay on the remote host.

Goal​

Run Claude Code against a repository on a server, cloud VM or dev box that you reach over SSH, and keep the session alive when your connection drops.

Prerequisites​

  • ssh my-host works from your computer. Put the host alias, user, key and any ProxyJump in ~/.ssh/config.
  • The remote machine meets Claude Code's system requirements: macOS 13 or later, Windows 10 1809 or later, or a supported Linux such as Ubuntu 20.04 or Debian 10, with 4 GB of RAM.
  • A Claude Pro, Max, Ultra, Team, Enterprise or Console account. The free plan does not include Claude Code.

Option 1: Terminal over SSH​

Connect, install Claude Code on the remote machine, and start it in the repository:

ssh my-host
curl -fsSL https://claude.ai/install.sh | bash
cd ~/src/my-repo
claude

The first run asks you to log in. Claude Code cannot open a browser on a remote machine, so press c to copy the login URL and open it in a browser on your computer. If the browser shows a login code instead of redirecting, paste it at the Paste code here if prompted prompt in the SSH session.

On a macOS host, the Keychain is often locked in an SSH session. Claude Code then stores the login in ~/.claude/.credentials.json with file mode 0600, the same file it uses on Linux.

For a host where you cannot finish a browser login, run claude setup-token on your own computer. It prints a one-year OAuth token. Set it on the remote machine as CLAUDE_CODE_OAUTH_TOKEN. That token cannot start Remote Control sessions or fetch claude.ai connectors.

Keep the Session Running​

A plain SSH session ends Claude Code when the connection drops. Start it inside tmux so it keeps running on the host:

tmux new -s claude # start a named session, then run claude
# press Ctrl-b, then d, to detach
tmux attach -t claude # reattach after you reconnect

To run several Claude Code sessions on one host, give each its own git worktree and its own tmux window. How to Run Multiple Claude Code Sessions shows the worktree setup.

Option 2: Claude Desktop SSH Sessions​

The Claude desktop app can drive Claude Code on a remote machine. The remote machine can run Linux, macOS or Windows. Desktop installs Claude Code under ~/.claude/remote/ on the remote host the first time you connect.

  1. Open the environment selector under the prompt box and select New environment.
  2. On the SSH tab, select Add SSH connection…. Enter a host such as user@hostname or an alias from ~/.ssh/config, and a Worktree folder such as ~/worktrees.
  3. Select a folder on the remote machine, click Create environment, and type your task.

A Linux or macOS host needs an x86_64 or arm64 processor, an SSH server with the SFTP subsystem, a home directory not mounted noexec, and about 1 GB of free disk. A task keeps running while Desktop is disconnected, but it can stop when your sign-in expires.

Option 3: Treq Remote SSH Workspaces​

Treq can open a repository on a machine you manage over SSH. The Treq window stays on your computer, and files, terminals and agents run on the remote host. Remote terminals and agents keep running when the connection drops, and Treq reattaches with the last 250 lines of output when you reconnect.

This is a Feature Preview. Turn on Remote SSH in Settings → Feature Preview, then choose File → Open via SSH.... Treq does not install anything on the host, so install the Treq CLI, jj, git and Claude Code there first. Remote SSH Workspaces lists what works today.

Common Failure Cases​

claude: command not found after install. The installer puts claude in ~/.local/bin. Open a new shell, or add that directory to PATH in the remote shell profile.

Login stops working on a long-running host. Run claude auth status --text to see when the stored login ends, and run /login again before that date.

Desktop cannot connect to a server with MaxSessions 1. Desktop logs in at least twice per connection. Raise MaxSessions in sshd_config, or follow the Desktop docs for your client platform.

Sources​

Checked December 5, 2026: