Running Claude Code on a remote server: what breaks and how to fix it
Claude Code runs fine on a remote Linux server over SSH, and moving it there keeps a busy agent from eating your laptop's memory and away from your personal files. What breaks are the parts that assumed the agent sits on your own computer: the session dies when SSH drops, notifications stop, Ctrl+V of a screenshot does nothing, scrolling in tmux misbehaves, you can't reach it from your phone, and you can't easily open the web app it just built. Each one has a do-it-yourself fix, listed below, and Zydra is one way to get all of them at once.
Why run Claude Code on a server at all?
Two reasons come up most. The first is memory: an agent that starts a dozen subagents, each running builds and tests, can fill a laptop's memory while you are trying to do something else. The second is reach: an agent with permission prompts turned off can read anything your user account can, including your SSH keys, browser profile and personal documents. A separate machine fixes both. That is why Zydra's builder moved their agents to a server in the first place, and then hit every problem in this article.
How do I keep the session alive when SSH disconnects?
Start Claude Code inside a terminal multiplexer, so it keeps running when your connection drops:
tmux new -s agent
claudeDetach with Ctrl+B then D, and come back later with tmux attach -t agent. Anthropic's own Remote Control docs give the same advice for remote machines: start claude inside tmux or screen.
herdr is a free, open-source alternative built for agents. It keeps terminals running in a background server when you close the client or lose SSH, and marks each pane as working, blocked or idle.
Why does scrolling break in tmux, and how do I fix it?
tmux draws its own screen, so your terminal's scrollback only sees what tmux last drew. On older tmux versions the mouse wheel does nothing useful until you turn on mouse support. Add this to ~/.tmux.conf:
set -g mouse onThen reload it with tmux source-file ~/.tmux.conf. The wheel now enters copy mode and scrolls tmux's own history; press q to leave copy mode. It works, but it is a different scrolling model from your terminal's, and selecting text with the mouse now goes through tmux too.
How do I get notifications from Claude Code on a server?
Claude Code sends a desktop notification when it finishes or waits for a permission answer and you seem to be away. In Kitty and Ghostty that notification travels back over SSH to your own notification center with no setup. iTerm2 needs its escape-sequence alerts turned on. Inside tmux, add set -g allow-passthrough on to ~/.tmux.conf, or tmux swallows it.
For your phone, or for terminals that show nothing, add a Notification hook that posts to ntfy. The notifications article has the exact config.
Can I paste screenshots into Claude Code over SSH?
Not with Ctrl+V on a plain server. Claude Code reads the clipboard of the machine it runs on, and a headless server has no clipboard with your screenshot in it. Copy the file over instead and give Claude the path:
scp ~/Desktop/shot.png server:/tmp/Then type /tmp/shot.png in your prompt. The image paste article covers the other options.
How do I check on the agent from my phone?
Two common routes. Install an SSH app such as Termius, connect to the server and run tmux attach -t agent. Or start Claude Code with claude --remote-control and open the session in the Claude app or at claude.ai/code. Remote Control needs a Pro, Max, Ultra, Team or Enterprise plan and doesn't work with an API key. The phone article compares them.
How do I see the web app the agent built?
Forward the dev server's port over SSH and open it locally:
ssh -L 5173:localhost:5173 serverThen browse to http://localhost:5173. With Tailscale on both machines you can skip the tunnel and open http://server:5173, as long as the dev server listens on all addresses. For Vite that means npm run dev -- --host.
Is it safe to run the agent on my production server?
No. An agent with broad permissions can delete files, rewrite git history or stop services, and on a production machine those are outages. Give it its own machine or VM, with only the credentials it needs. Sandboxing AI coding agents compares containers and microVMs.
What does Zydra do about all this?
Zydra gives each account its own virtual machine with a Linux desktop that draws inside your terminal over SSH. The desktop keeps running after you disconnect, so agents keep working without tmux. Its terminal keeps 10,000 lines of history and the mouse wheel scrolls it.
Notifications from programs in the VM reach your terminal as normal desktop notifications, and your phone gets them as push notifications once you pair it. Ctrl+V in Claude Code fetches the image from your own computer's clipboard, through a terminal that supports Kitty's clipboard protocol, such as Kitty. The phone view shows your windows live and lets you type into them.
The browser runs inside the VM, next to the agent, so there is no port to forward. Agents can open their page in a tile beside themselves and screenshot it. If an agent wrecks something, the timeline rewinds the whole machine to an earlier point.
The trade-off is price and control. Zydra costs $40 a month for one VM with 8 GB of memory and 80 GB of storage. A small VPS, or a spare machine at home, costs less and gives you full control of hardware you pick.
Try it
Run ssh zydra.sh in your terminal. The demo is free for 15 minutes and needs no sign-up.
Related: What is Zydra? and Get notified when Claude Code needs you on a remote machine. Or browse all articles.