How to Run Claude Code from Your Phone
Claude Code no dey run for your phone. E dey run inside tmux for VPS, while SSH, mosh, tmux attach, and better keyboard settings keep am usable on flaky mobile data.
Claude Code from your phone: how e dey really work
Claude Code from your phone no be mobile app. Claude Code dey run for VPS (virtual private server), inside tmux session wey stay open, and your phone dey open SSH (secure shell) connection to that session as long as you dey look am. If you close the app, the agent go continue to work, because the process never dey run for the phone.
That separation na the whole design. Phone operating system dey suspend app seconds after you switch comot from am, so any long job wey you start for phone go stop. E still dey get new network address every time you move from wifi go mobile data. When the process dey run for server and phone only dey show the screen, both problems go away.
You need four things for the server: tmux to hold the session, SSH keys to enter, mosh for network changes, and Claude Code itself. For the phone side, na one terminal app with a key row wey you fit reach.
Wetin you need for the VPS
One small Ubuntu 24.04 box dey enough for the SSH and tmux parts. Claude Code need more. The official requirements as of July 2026 na Ubuntu 20.04 or newer for x64 or ARM64 processor, with 4 GB or more RAM. A 1 GB plan fit install am, but kernel go kill the process when load high. Claude Code also need paid Claude account (Pro, Max, Team or Enterprise) or Console account with API access, because free Claude.ai plan no include am.
Set up the box with ordinary user wey get sudo, no be root. If the server new, first follow the first ten minutes for new VPS, because the SSH changes later for this guide dey easier after the user and firewall don exist.
sudo apt update && sudo apt install -y tmux mosh
curl -fsSL https://claude.ai/install.sh | bash
claude --versionThe installer dey put the binary for ~/.local/bin/claude, and claude --version dey print line like 2.1.211 (Claude Code). If e print command not found, that directory never dey for your PATH: log out, log back in, then check with command -v claude. claude doctor dey print installation and settings diagnostics without starting session.
Log in once now from laptop, before you depend on phone. Run claude inside project directory and follow the login prompt. The flow go ask you to open URL for browser and bring code back to terminal, and switching between two apps for phone screen slow. Do am once with real keyboard, and the credentials go remain for server.
Start Claude Code inside tmux so connection wey drop no fit kill am
tmux new -s claude
cd ~/projects/api
claudeDetach with Ctrl-b and then d. tmux go print [detached (from session claude)] and hand shell back to you. Now close the app, lose signal, or put the phone for your pocket. The pane go continue to run.
tmux ls
tmux attach -t claudetmux ls go print one line for each session, like claude: 1 windows (created Thu Jul 30 09:14:02 2026). tmux attach -t claude go put you back exactly where you stop, including the edit wey you never finish.
This one work because tmux dey run e own server process, and your shell plus Claude Code na children of that server, instead of sshd. When SSH connection end, kernel go send hangup signal, SIGHUP, to processes wey dey attached to that connection, but tmux server no dey among dem. Without tmux, the same screen lock wey drop your connection go stop Claude Code in the middle of tool call. Run Claude Code for VPS inside tmux explain the session layout more.
Run tmux for the server, never for the phone. If you type tmux inside session wey you already attach to, e go print sessions should be nested with care, unset $TMUX to force, and if you force am, you go get two prefix keys wey go dey clash.
Login time, make e attach automatically
To dey type attach command for touch keyboard fit tire person. Put this one for the end of ~/.profile for the server:
if command -v tmux >/dev/null 2>&1 && [ -z "$TMUX" ] && [ -t 1 ]; then
exec tmux new-session -A -s claude
finew-session -A -s claude go attach to the session wey dem name claude if e dey, and e go create am if e no dey. So, one command cover both cases. exec go replace the login shell with tmux, so when you comot from tmux, e go close the connection instead of leaving you for plain prompt. When you need plain shell, skip the file: ssh you@server -t "bash --noprofile".
Put am for ~/.profile, no be for ~/.bashrc. ~/.bashrc dey also run for non-interactive sessions, so file transfers go break: scp and sftp go read the unexpected output as protocol data and fail with Received message too long. ~/.profile dey run for login shells only, and na that interactive SSH session dey use.
~/.profile na also where Ubuntu dey add ~/.local/bin to PATH. If claude dey work immediately after login but shell wey dey inside tmux talk say command not found, na this ordering cause am. Start tmux from login shell as shown above, instead of from script wey skip the profile.
iOS: Termius or Blink Shell
Both apps dey support SSH and mosh, and both dey store keys inside the app. The main difference na the interface.
Blink Shell dey use commands. For the prompt, type ssh you@server or mosh you@server, with the same syntax wey desktop terminal dey use. To open settings, type config. The Keys section fit create key pair for you.
Termius dey use forms. Fill in host entry, then change that host from SSH to Mosh inside the host details. Termius get its own mosh implementation and e support mosh 1.3.0 and newer, so server still need to get mosh package installed.
Generate the key inside the app for both cases. Never copy existing private key enter the phone. The app go show you the public half. Na that single line you go add to ~/.ssh/authorized_keys for the server. Per-device SSH keys and how to revoke one explain the naming and revoke step. This one matter more for phone than laptop.
Turn on the terminal app own biometric or passcode lock. If you no turn am on, anybody wey unlock the phone get open shell access to your server as long as the screen still dey awake.
Android: Termux
pkg upgrade
pkg install openssh mosh
ssh-keygen -t ed25519 -C "pixel"
cat ~/.ssh/id_ed25519.pubTermux dey package OpenSSH and mosh for im own repository, so ssh, ssh-keygen and mosh dey work the same way dem dey work for desktop. Add the public key line wey e print to ~/.ssh/authorized_keys for the server, then connect with mosh you@server.
Android on-screen keyboard no get Esc key and no get Ctrl key, and Claude Code need both. Termux fit draw im own key row. Put one line for ~/.termux/termux.properties:
extra-keys = [['ESC','|','/','HOME','UP','END','PGUP'],['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]Then run termux-reload-settings and the row go show above the keyboard. The same reload go also pick up monospace TrueType font wey you drop for ~/.termux/font.ttf.
Android fit stop Termux while e dey background, and for this case you no lose anything except say you go reconnect. The session and the agent dey for the server.
Why terminal dey freeze when I comot from wifi, and wetin mosh fix?
SSH connection na TCP (transmission control protocol) connection, and TCP connection dey identified by both addresses and both ports. When you waka comot from wifi range, phone go get new address from mobile network, so the old connection no longer match anything for either side. Nothing dey announce this. Terminal just stop to respond until TCP give up, then ssh go print client_loop: send disconnect: Broken pipe. To kill frozen session immediately, press Enter, then ~, then ..
mosh (mobile shell) remove this failure mode. E use SSH once to log in and start one mosh-server process, read back the UDP (user datagram protocol) port wey server pick, then close the SSH connection. After that, both sides exchange UDP datagrams wey shared session key authenticate, so na that key identify the session, no be your address. New address just continue the session. mosh also echo your typing locally and repaint the screen when server response no agree, na why e remain usable for slow mobile link.
mosh dey use UDP port between 60000 and 61000, so open that range:
sudo ufw allow 60000:61000/udp
sudo ufw statusHow to open ports with ufw get the remaining firewall details. If your provider offer separate network firewall for control panel, add the same range there too, because ufw rule no fit affect filter wey dey in front of the machine.
Two mosh failures dey common. If login succeed and then hang, showing Nothing received from server on UDP port 60001., e mean say something block that UDP range between phone and server. If connection report mosh-server not found, e mean say package no dey installed for server or e no dey inside login PATH. Install am, or point to am directly with mosh --server=/usr/bin/mosh-server you@server.
mosh also no go run when login locale no be UTF-8, and e go talk so: mosh-server needs a UTF-8 native locale to run. Fix the locale for server, no be for phone.
locale
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8Two things mosh no dey do. The README state say mosh no support X forwarding or the non-interactive uses of SSH, including port forwarding, so to preview web app wey Claude Code just start still need plain ssh -L 8080:127.0.0.1:8080 you@server. E also synchronise only the screen wey dey visible, so e no get scrollback of its own. That second limit no cost anything here, because tmux keep the scrollback: Ctrl-b then [ enter copy mode, drag or arrow keys go scroll, and q comot.
Make phone screen useful
Four lines for ~/.tmux.conf for server dey do most of the work:
set -g mouse on
set -g status-position top
set -g default-terminal "tmux-256color"
set -g history-limit 20000mouse on dey turn touch drag to scroll and tap to pane or window selection. This replace most prefix keys wey hard to type. status-position top dey move tmux status line comot from bottom edge, where on-screen keyboard and suggestion bar dey cover am. default-terminal matter because tmux otherwise dey announce screen terminal to Claude Code, and colours plus box drawing no go come out as well as dem suppose. If tmux then refuse to start with missing or unsuitable terminal: tmux-256color, e mean say terminfo entry no dey: sudo apt install ncurses-term.
Learn four keys and the rest go dey comfortable.
Escdey interrupt Claude for middle of response and keep the work wey e don do already. Na the key wey you want near your thumb.Ctrl+Cdey interrupt running operation too. For idle prompt, the first press dey clear the input and second press dey exit Claude Code. So na the more blunt tool.Esctwice dey clear draft prompt, and for empty prompt e dey open rewind menu instead.- For multi-line prompt, type
\then press Enter. This form dey work for every terminal. Shift+Enter dey native only for small list of desktop terminals, and mobile clients no dey inside am.
Avoid split panes. Phone wey dey portrait mode dey around 40 columns wide, so vertical split go leave 20 columns for each pane and every diff go wrap into noise. Use tmux windows instead: Ctrl-b c dey create one and Ctrl-b n dey move go the next one. If second window end up with its own Claude Code session, the two sessions fit hand work to each other directly instead of you copying text between windows for touchscreen. Turn the phone sideways when you need read diff properly.
How much text wey go show for that screen worth setting deliberately, because output style dey edit the system prompt behind every reply and terser one mean say you go scroll pass fewer screenfuls for phone.
Long session for small screen na mostly context problem. So managing Claude Code context window worth reading before you try run full day of work from train.
Lock am down: keys only, no passwords
The phone now hold a key wey fit enter machine wey dey edit your code and run commands. Off password authentication. Drop-in file safer pass editing sshd_config directly, because Ubuntu sshd_config get /etc/ssh/sshd_config.d/*.conf for top and na the first value wey e find for setting dem dey use.
sudo tee /etc/ssh/sshd_config.d/99-phone.conf >/dev/null <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
PermitRootLogin no
EOF
sudo sshd -t && sudo systemctl reload sshsshd -t dey parse the config and print nothing when e valid. If you skip am, one typo fit make sshd fail when e reload. Keep your current session open and test from another connection before you close anything, because wrong key go give you Permission denied (publickey). now, and since passwords dey off, no fallback dey. For that situation, na your provider console be the recovery path.
Give every device e own key. If phone loss, you only need delete one line from ~/.ssh/authorized_keys, and your laptop go still work. If na one shared key, you go need change the key for every device wey you own.
If you move SSH go another port for Ubuntu 24.04, remember say ssh.socket own the listener, so Port line by itself no go change anything. Run sudo systemctl edit ssh.socket, clear the default with empty ListenStream=, then set your port for the next line. How to harden SSH for VPS cover that and the remaining attack surface.
fail2ban for SSH add small security once passwords dey off, because system no fit accept guessed password at all. Wetin e add na quieter logs, so real login attempt go easy to notice.
The stronger option na to keep SSH off public internet. Put the server behind WireGuard VPN wey you host yourself, bring the tunnel up for phone whenever you need am, and give sshd a ListenAddress only for the tunnel. mosh dey work through the tunnel because both sides use UDP. One thing to note: the tunnel add packet overhead, so if large transfers stall, reduce the MTU (maximum transmission unit) for the phone WireGuard config.
One last point about this way of working. From phone, you dey approve permission prompts for screen wey dey show only few diff lines at a time. That na reason to keep the guardrails, no be to switch dem off. How to run Claude Code safely for VPS explain the user and directory limits wey you suppose set before touchscreen become your main way to enter.
When you reattach and something is wrong
tmux attach printing no server running on /tmp/tmux-1000/default means the tmux server don disappear, and most times na because the machine reboot. Check with uptime. Kernel updates from automatic security updates fit reboot the box, and rebooted box no get tmux session. So treat any Claude Code run as something wey you fit restart.
can't find session: claude different. The tmux server dey run, but that name no dey there. tmux ls go show wetin dey exist.
If you attach and see plain shell prompt where Claude Code dey before, the process don end but the session never end. Check dmesg -T | tail for line like Out of memory: Killed process 4821 (claude). Na this box wey get less than 4 GB requirement dey do during large edit. If you no see that line, Claude Code exit by itself, and the shell scrollback above the prompt get the reason.
If window come back tiny, with unused space around am, e mean say two clients attach with different sizes. tmux sizes window to fit the smallest attached client. Your laptop still dey hold the session at 200 columns wide, while the phone dey request 40. Detach the other clients as you attach: tmux attach -d -t claude.
FAQ
I fit run Claude Code for the phone itself instead of VPS?
No. The platforms wey support am as of July 2026 na macOS, Windows, Ubuntu 20.04 or newer, Debian 10 or newer, and Alpine 3.19 or newer, with 4 GB or more RAM. Android and iOS no dey that list. Phone dey sleep apps, and e dey change network address often, wey long agent run no fit tolerate. Run am for server, then use phone as display.
Session go survive if I close the app or lose signal?
Yes, and two separate things dey handle am. tmux keeps the process running for server, so nothing go die when connection end. mosh keeps the connection itself alive when address change, so switching from wifi to mobile data no even require reconnect. With plain SSH and no tmux, dropped connection sends SIGHUP and Claude Code stops in the middle of task.
Why mosh dey connect, then show nothing?
If login succeed and then hang with Nothing received from server on UDP port 60001., e mean say UDP 60000 to 61000 no open. Add the range for ufw, and add am again for your provider network firewall, because na separate control for most panels. If mosh instead report say mosh-server no dey found, server no get the package: sudo apt install mosh.
How I fit interrupt Claude Code from keyboard wey no get Esc key?
Add key row. Termux configures one with extra-keys for ~/.termux/termux.properties, and Termius and Blink both ship row wey you fit edit for settings. Esc interrupts response wey dey run and keeps the work wey e don do. Ctrl+C too dey interrupt, but if you press am twice when prompt dey idle, e go exit Claude Code, so use Esc first.
Opening SSH to internet safe enough for this?
If password authentication dey off, the only credential wey fit succeed na key wey never leave your devices. For machine wey you fit rebuild, this na reasonable risk. Give each device its own key, so if phone loss, na one line for authorized_keys you go remove. If you no wan answer on public port at all, put the box behind WireGuard and make sshd listen on the tunnel address.