Keep Claude Code Running After SSH Disconnects: A tmux Recipe
Keep Claude Code alive after an SSH disconnect with tmux. Reconnect to the same process, check persistence, and use AgentsRoom's opt-in setting.
The agent is working on your server. You close the laptop. When you return, there is no process to return to.
We received exactly this request: persistent remote sessions that survive a client disconnect, so the user can continue from another machine. Our SSH launch already ran the CLI on the host. That was insufficient: the process still depended on the interactive SSH terminal.
We shipped the change in AgentsRoom 1.198.0. Here is the manual recipe first, then what the app does with it. The same lifecycle issue applies to Claude Code, Codex and other interactive coding CLIs.
The terminal needs to outlive the connection
Our ordinary remote launch used an SSH channel with a terminal attached. If that channel disappears, the host can send a hangup signal and the agent dies. A process being remote does not by itself make it persistent.
tmux gives the process a terminal that lives on the host independently of the viewer. Its getting-started guide describes this exact use: protecting remote programs from connection drops and accessing them from another computer.
This is about keeping a process alive. For the broader choice between cloud sessions, a phone remote and your own server, read the three meanings of remote agents.
Start tmux before the agent
On a Unix-like host, connect with your usual SSH alias. Replace the repository path with yours:
ssh my-server
tmux -V
tmux new-session -s coding
cd ~/projects/my-repo
claude
For Codex, use codex in the last line instead. The CLI needs to be installed and signed in on the server. Start with a repository you can afford to experiment on.
Detach with Ctrl+B, then D. Reconnect later:
ssh my-server
tmux list-sessions
tmux attach-session -t coding
The tmux manual documents detach and attach. Reattachment returns to the live terminal. It does not send the task again or launch another agent.
Check the lifecycle before giving it real work
You can check the recipe without consuming an agent quota. Inside the new tmux session, run this finite command instead of a CLI:
python3 -u -c 'import time; [(print(i, flush=True), time.sleep(1)) for i in range(60)]'
Detach, disconnect SSH and attach again within a minute. The numbers should have advanced while you were away. This is a procedure for your host, not a benchmark we ran across every server configuration.
Next, try a short agent task. After reconnecting, check the files it changed and whether it needs an answer. A session can survive while the agent waits at a permission prompt. Keeping it alive does not make it autonomous.
What we changed in AgentsRoom
Open the saved SSH connection and enable Keep agents running on this host when AgentsRoom closes. It is off by default. The host needs tmux 3.0 or later.
Now open a remote project and launch an agent there. The CLI runs inside a named tmux session on the host. Quitting AgentsRoom, sleeping the laptop or losing the connection leaves that session alone. Opening the same saved agent again attaches to it, including from another computer on your account.
We made four implementation choices because each one changes what a user experiences:
- The session name follows the agent identity. Reopening that agent finds its process; a new agent gets a new session.
- The app uses a separate tmux server and skips your personal tmux configuration. It does not rearrange the sessions you manage by hand.
- The tmux prefix is disabled inside the app. Ctrl+B remains available to the coding CLI, and Escape reaches it without tmux's usual delay.
- An explicit agent restart replaces the remote process. Quitting the app detaches its viewer. Those gestures must have different effects.
The last distinction matters most. Closing the agent tab is not the way to leave it working. Quit the app or disconnect the viewer. If you explicitly close or restart the agent, AgentsRoom attempts to stop the remote session too; if the host is unreachable, it cannot guarantee that stop.
If tmux is absent or too old, the app launches as it did before. Do not assume the checkbox alone proves persistence: check the host and do the disconnect exercise. These details were checked against the published implementation on 7 October 2026.
Where nohup and Mosh fit
nohup makes a command ignore hangup signals, as its manual explains. It does not give you an interactive terminal to attach to later. It suits a batch command with redirected input and output better than an agent that may ask a question.
Mosh handles intermittent connections and changes of network. Its documentation also warns that it synchronizes the visible screen rather than complete scrollback. It can be used with tmux; keeping a session available after deliberately exiting the client is a separate concern from roaming between networks.
What persistence does not solve
The host still has to stay on. A reboot ends its live processes. A quota limit, a CLI crash or a permission question can still stop progress. You reconnect to the current screen; the console history your other computer displayed is not promised to reappear in full.
Keep the work in files the next session can read: a short task note, the changes themselves and the verification result. A surviving terminal is useful. A task whose state exists only in that terminal is still fragile.
The remote-access page covers how to reach your agents. This recipe covers the next question: whether there is still an agent to reach after the connection goes away.
Questions
Does a coding agent on a server survive an SSH disconnect?
A plain interactive SSH terminal is not a persistence mechanism. Losing its terminal can stop the agent. Run it inside tmux on the server before disconnecting, then attach to that session again. The server must remain running, and the agent can still stop for its own reasons.
Can I reconnect from another computer?
Yes, connect to the same server as the same host user and attach to the named tmux session. In AgentsRoom, enable persistent sessions for the SSH connection, then open the same saved agent from another computer on your account. Starting a different agent creates a different session.
Is reconnecting the same as resuming a conversation?
No. Attaching to a live tmux session returns to a process that never stopped. Resuming a saved conversation launches a process that reads the CLI's history. A conversation file cannot restore a running command or a terminal process that has died.
Does closing AgentsRoom stop a persistent remote agent?
Quitting the app leaves it running when the SSH connection's persistent-session option is enabled and tmux 3.0 or later is available on the host. Explicitly closing or restarting the agent asks to stop or replace its process; an unreachable host cannot confirm that action. Without a supported tmux, the launch falls back to the ordinary SSH behavior.
AgentsRoom 다운로드
모든 AI 에이전트를, 모든 프로젝트에서, 하나의 창으로 실행하세요.
컴패니언 앱: 이동 중에도 에이전트를 모니터링
Claude, Codex, Antigravity CLI 또는 다른 AI 공급자를 사용하세요.
버그와 요청을 공개 백로그로 바로 보내세요.
계속 읽기
\"Claude remote agents\"가 실제로 뜻하는 것: cloud session, 원격으로 조종하는 로컬 세션, 또는 내가 소유한 머신
Claude remote agents를 검색하는 사람들은 서로 다른 세 가지에 도착합니다. Anthropic의 cloud session(Claude Code on the web, claude --cloud, Routines), Remote Control(여러분의 컴퓨터에서 도는 세션을 폰에서 조종하는 것), 그리고 여러분이 소유한 머신에서 SSH로 돌아가는 에이전트입니다. 각각이 무엇인지 2026년 9월 28일 Anthropic 문서로 확인한 내용, 어느 것이 어디서 돌아가는지, 무엇이 필요한지, 그리고 어떤 에이전트 CLI로든 저희가 각 경우를 어떻게 다루는지 정리했습니다.
기사 읽기Claude Code Remote Control은 토큰을 더 쓰나요? 그리고 Codex에도 있나요?
Anthropic이 Remote Control을 내놓은 뒤로 사람들이 Google에 치는 두 가지 질문: 폰에서 Claude Code 세션을 조종하면 토큰이 더 드는지, 그리고 Codex에도 같은 것이 있는지. 짧은 답은, 아니요, 턴은 어디서 치든 턴입니다, 그리고 네, 하지만 절반만 존재합니다. Remote Control이 실제로 무엇인지, 토큰 질문을 명령 네 개로 직접 재는 방법, codex remote-control이 오늘 하는 일, 그리고 제공자와 한 번도 대화하지 않는 모바일 리모컨이 계산을 어떻게 바꾸는지 정리했습니다.
기사 읽기Claude Code의 Routines: 클라우드에서 도는 것, 내 컴퓨터에 남는 것, 그리고 고르는 법
Routines는 저장해 둔 프롬프트를 여러분 없이 실행하는 Claude Code의 방식입니다. 예약 시각에, API 호출로, 또는 GitHub 이벤트로 시작되며, 저장소를 새로 클론한 cloud session으로 돌아갑니다. 지금은 리서치 프리뷰 단계입니다. Claude Code에는 작업을 로컬에서 예약하는 방법도 두 가지(데스크톱 앱의 예약 작업과 /loop) 있는데, 셋은 똑같이 동작하지 않습니다. 최소 간격, 로컬 파일 접근, 권한 확인, 노트북이 잠자기에 들어갔을 때 일어나는 일이 다릅니다. 이 가이드는 문서에 적힌 제약과 함께 셋을 정리하고, 저희의 야간 에이전트 일곱 개가 왜 로컬 머신에서 돌아가는지 설명합니다.
기사 읽기