Claude Code Remote Control: Run It From Your Phone or Another Machine
By: Evgeny Padezhnov
Claude Code runs in a terminal. That terminal does not have to be on the machine in front of you. A phone, a tablet, or a second laptop can drive a session on a beefier host. The trick is keeping the session alive when the connection drops.
Long agent runs are the problem. A refactor or a test loop can run for 20 minutes. A phone locks the screen. Wi-Fi hands off to cellular. The SSH pipe breaks, and a naive session dies with it. The fix is a persistent terminal plus a secure path to reach it. This guide covers both, with commands.
The core problem: a raw SSH session is fragile
Open a plain SSH connection and run claude. Close the laptop lid. The session dies. Any in-progress edit or command is gone.
In plain terms: SSH ties the process lifetime to the network link. Break the link, kill the process. Remote Claude Code needs a session that outlives the connection.
Two tools solve this: tmux and screen. Both are terminal multiplexers. They run a shell on the server, detached from your client. You attach and detach at will. The process keeps running in between.
Key point: run Claude Code inside the multiplexer, not next to it. The agent lives on the server. The phone is only a window.
Option 1: tmux plus SSH (the default setup)
This is the most reliable self-hosted method. It works on any Linux or macOS host with a shell.
Install tmux first. On Debian or Ubuntu:
sudo apt install tmux
Start a named session on the host:
tmux new -s claude
Inside that session, launch the agent:
claude
Now detach without stopping anything. Press Ctrl-b, then d. The session drops to the background. Claude Code keeps running.
Reattach later from any device:
tmux attach -t claude
List running sessions with tmux ls. Kill one with tmux kill-session -t claude.
Tested in production. A tmux session survives a dropped SSH pipe, a locked phone, and a Wi-Fi-to-cellular handoff. Reconnect and the agent is still there, mid-task.
screen does the same job with different keys. Start with screen -S claude. Detach with Ctrl-a then d. Reattach with screen -r claude. Pick one tool and learn its two shortcuts. See the tmux wiki for the full command set.
Common mistake: running claude in a bare SSH shell and expecting it to persist. It will not. The multiplexer is the load-bearing part.
One session, many screens
tmux allows several clients on the same session at once. Attach from a laptop and a phone together. Both see the same live terminal. Useful for starting a long run on a big monitor, then watching it finish from a phone on the move.
Option 2: mosh for phone connections
SSH assumes a stable IP and a steady link. Phones break both assumptions. Cellular networks change your IP. Signal drops in tunnels and elevators. Each change stalls or kills an SSH session.
mosh (mobile shell) fixes this. It keeps a session alive across IP changes and network gaps. It uses UDP, predicts input locally, and resyncs when the link returns. Typing feels instant even on high latency.
Install mosh on both the host and the client. On the host:
sudo apt install mosh
Connect:
mosh user@host
mosh opens SSH to authenticate, then switches to its own UDP channel on ports 60000–61000. Open that range on the host firewall.
Key point: mosh replaces the transport, not the session. Run tmux inside mosh for the best of both. mosh survives the network; tmux survives the disconnect. Details are on the mosh project site.
In practice this pairing is what makes phone-driven coding tolerable. Ride a train, lose signal for a minute, keep the session. The agent never notices.
Phone and tablet clients that work
The host is ready. Now pick a client that speaks SSH or mosh.
- Termius (iOS and Android): SSH, saved hosts, key storage, and a usable on-screen key row with
CtrlandTab. The paid tier syncs hosts across devices. - Blink Shell (iOS): supports both SSH and mosh natively. Fast, keyboard-focused, built for exactly this use case.
- Termux (Android): a full Linux environment. Install
opensshandmoshwithpkg install, then connect like a desktop.
Common mistake: using a client without a physical or well-designed on-screen Ctrl key. Claude Code and tmux both need Ctrl and Esc constantly. A client that hides those keys makes the session unusable. Test the key row before trusting a tool.
Try it: pair a Bluetooth keyboard with the phone. A remote Claude Code session with a real keyboard turns a phone into a working terminal. Screen size is the only real limit.
Option 3: Claude Code on the web and the mobile app
Not everyone wants to run a host. Anthropic ships a hosted path too.
Claude Code runs on the web at claude.ai/code and inside the Claude mobile app. Sessions execute in cloud sandboxes, not on your machine. Connect a GitHub repository, describe the task, and the agent works in an isolated environment. Access is included with a Pro, Max, Team, or Enterprise plan (currently a research preview).
The trade-off is control. The hosted sandbox handles environment and persistence for you. It does not touch your local files, your private network, or tools that only exist on your own server. The SSH-plus-tmux path does all of that, at the cost of running the host yourself.
Choose by need. Hosted web and mobile suit quick tasks against a GitHub repo from anywhere. Self-hosted SSH suits work that must run on a specific machine — a staging server, a GPU box, a private network. Check the current capabilities in the Claude Code documentation before deciding, since the hosted product evolves quickly.
Securing remote access
Reaching a host from a phone means exposing a way in. Do it carefully.
Never expose SSH on port 22 to the open internet with password login. Automated bots scan that port constantly. Two rules cut nearly all of that risk.
First, use key authentication only. Generate a key:
ssh-keygen -t ed25519
Copy the public key to the host, then disable passwords in /etc/ssh/sshd_config:
PasswordAuthentication no
PubkeyAuthentication yes
Reload with sudo systemctl reload ssh. Now a stolen password is worthless, because passwords no longer work.
Second, avoid exposing SSH publicly at all. Put the host on a private mesh network. Tailscale builds a WireGuard-based network across your devices with almost no config. The phone and the host join the same tailnet. SSH targets the private Tailscale IP. The host stays invisible to the public internet.
Key point: a private mesh removes the attack surface entirely. There is no open port for a scanner to find. The phone reaches the host as if both sat on the same LAN.
For a self-managed alternative, raw WireGuard does the same job with more setup. Either way, the goal is one thing: the SSH port is never reachable from a random IP.
Headless mode for automation and triggers
Interactive sessions are one use. Scripted runs are another. Claude Code has a print mode for non-interactive work:
claude -p "run the test suite and summarize failures"
The -p flag sends one prompt, prints the result, and exits. Add --output-format json to get structured output for a script to parse. This turns Claude Code into a command you can call from anything — a cron job, a webhook handler, a CI step.
That opens a remote-trigger pattern. A phone sends a message to a small webhook on the host. The webhook runs claude -p with a fixed prompt. The result comes back as a notification. No interactive terminal needed. The phone becomes a trigger, not a keyboard.
Common mistake: granting a headless run unlimited permissions on a shared or production host. Scope it. Run it as a limited user. Restrict which directories and commands it can touch. An unattended agent with full shell access on a live server is a real risk, not a convenience.
An unattended run also needs limits set in advance. A first Claude Code mod that blocks dangerous commands refuses rm -rf /, force pushes and destructive SQL before they reach the shell. A 30-line mod that tracks and caps spend keeps a run nobody is watching inside the budget.
Putting it together
The reliable stack for phone-driven Claude Code is three layers:
- Transport: mosh, or plain SSH on a stable link.
- Persistence: tmux or screen, so the session outlives the connection.
- Access: a private mesh like Tailscale, plus key-only authentication.
Add the hosted web and mobile app for quick GitHub tasks that do not need your own machine. Add headless claude -p for triggered and automated runs.
If it works — it is correct. A session that reconnects mid-task, on a locked-down path, from a phone, is the whole goal. Everything above serves that one outcome.
What to try right now
Set up the minimum viable version in five minutes. On the host, run tmux new -s claude, then start claude inside it. Detach with Ctrl-b d. From your phone, install Termius or Blink Shell, add the host, and run tmux attach -t claude. The live session appears on the phone.
Try it: start a long task on the host, detach, close the laptop, and reattach from the phone. Watching the same run continue on a different device is the moment remote Claude Code clicks. Harden the access path with key-only SSH and Tailscale before using it on anything that matters.
Information is accurate as of the publication date. Terms, prices, and regulations may change — verify with relevant professionals.