How to Use Claude Code from Your Phone
Claude Code no dey run for your phone. E runs inside tmux on VPS, while SSH keys, mosh, tmux attach, and keyboard fixes keep am usable on mobile.
Claude Code from your phone: how e dey work for real
Claude Code from your phone no be mobile app. Claude Code dey run for VPS (virtual private server), inside tmux session wey dey remain open, and your phone dey open SSH (secure shell) connection to that session for as long as you dey look am. Close the app and the agent still dey work, because the process no ever dey run for the phone.
That split na the whole design. Phone operating system dey suspend app some seconds after you switch commot from am, so any long job wey you start for phone go stop. E also dey get new network address every time you waka from wifi enter mobile data. Both problems go disappear when the process dey run for server and the phone only dey show the screen.
You need four things for the server: tmux to hold the session, SSH keys to enter, mosh for the network changes, and Claude Code itself. The phone side na one terminal app wey get 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 go install am, but kernel go later kill the process when load high. Claude Code still need paid Claude account (Pro, Max, Team or Enterprise) or Console account wey get 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 on a new VPS, because the SSH changes later for this guide dey easier after user and firewall don dey.
sudo apt update && sudo apt install -y tmux mosh
curl -fsSL https://claude.ai/install.sh | bash
claude --versionThe installer go put the binary for ~/.local/bin/claude, and claude --version go print line like 2.1.211 (Claude Code). If e print command not found, that directory never dey for your PATH: log out, log in again, then check with command -v claude. claude doctor go 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. Doing this with two apps for phone screen dey slow. Do am once with real keyboard, and the credentials go remain for server.
Start Claude Code inside tmux make connection 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 give you back the shell. Now close the app, lose signal, or put the phone for 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 carry you go back exactly where you stop, including the edit wey never finish.
This one work because tmux dey run im own server process, and your shell plus Claude Code na children of that server, not of sshd. When the SSH connection end, the kernel dey send the hangup signal, SIGHUP, to processes wey dey attached to that connection, and tmux server no dey among dem. Without tmux, the same screen lock wey dey drop your connection go stop Claude Code for middle of tool call. Running 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 don 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 fight each other.
Cada login dey attach automatically
To type the attach command for touch keyboard every time no dey convenient. Put dis 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 dey attach to the session wey dem name claude if e dey exist, and e dey create am if e no dey exist. So, one command dey handle both cases. exec dey replace the login shell with tmux. So, when you comot from tmux, e dey close the connection instead of leaving you for empty 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 dey fail: scp and sftp dey 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 dey show command not found, na that order cause am. Start tmux from login shell as described above, instead of starting am from script wey skip the profile.
iOS: Termius or Blink Shell
Both apps dey speak SSH and mosh, and both dey store keys inside the app. The difference na the interface.
Blink Shell dey use commands. For the prompt, you type ssh you@server or mosh you@server, na the same syntax wey desktop terminal dey use. You open settings by typing config, and the Keys section go create key pair for you.
Termius dey use forms. You go fill host entry, then change that host from SSH to Mosh for the host details. Termius get im own mosh implementation and e support mosh 1.3.0 and newer, so the server still need get mosh package installed.
Generate the key inside the app for both cases, and never copy existing private key enter the phone. The app go show you the public half. Na this 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, unlocked phone go give anybody open shell access to your server for as long as the screen 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 its 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 its 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 pick monospace TrueType font wey you put for ~/.termux/font.ttf.
Android fit stop Termux when e dey run for background, and for here, na only reconnect you go need. The session and the agent dey for the server.
Wifi connection chenj, terminal freeze kenapa, and wetin mosh dey fix?
SSH connection na TCP (transmission control protocol) connection, and TCP connection dey identify with both addresses and both ports. If you waka commot from wifi range, phone go get new address from mobile network, so the old connection no 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) dey remove this failure mode. E use SSH once to log in and start mosh-server process, read back the UDP (user datagram protocol) port wey server pick, then close the SSH connection. After that, both sides dey exchange UDP datagrams wey shared session key authenticate, so the session dey identify with that key, no be with your address. New address just continue the session. mosh still dey echo your typing locally and repaint when server 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 get separate network firewall for im 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 UDP range dey blocked somewhere between phone and server. If connection report mosh-server not found, e mean say package no dey 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 still 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. Its README talk say mosh no support X forwarding or SSH non-interactive uses, 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 im own scrollback. This second limit no cost anything here, because tmux dey keep the scrollback: Ctrl-b then [ enter copy mode, drag or arrow keys dey scroll, and q comot.
Make phone screen work well
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 select pane or window. Dis replaces most prefix keys wey hard to type. status-position top dey move tmux status line away from the bottom edge, where on-screen keyboard and suggestion bar dey cover am. default-terminal matter because tmux otherwise dey tell Claude Code say na screen terminal e dey use, and colours plus box drawing no go come out as well as dem suppose. If tmux later refuse to start with missing or unsuitable terminal: tmux-256color, the terminfo entry no dey available: sudo apt install ncurses-term.
Learn four keys, and the rest go comfortable.
Escdey interrupt Claude while e dey answer, but e keeps the work wey e don already do. Na the key wey you want near your thumb.Ctrl+Cdey interrupt running operation too. For idle prompt, the first press clears the input, and the second press exits Claude Code. So na the more forceful option.Esctwice dey clear draft prompt. For empty prompt, e opens the rewind menu instead.- For multi-line prompt, type
\and then Enter. Dis form dey work for every terminal. Shift+Enter na native only for small list of desktop terminals, and mobile clients no dey among dem.
Avoid split panes. Phone for portrait mode dey around 40 columns wide, so vertical split leaves 20 columns for each pane, and every diff go wrap into noise. Use tmux windows instead: Ctrl-b c creates one, and Ctrl-b n moves to the next one. Turn the phone sideways when you need read diff properly.
Long session for small screen na mostly context problem, so how to manage Claude Code context window worth reading before you try run full day of work from train.
Lock amara: keys nikan, password ò si
Foonu dey hold key now to one machine wey dey edit your code and run commands. Off password authentication. Drop-in file dey safer pass to edit sshd_config directly, because Ubuntu sshd_config dey include /etc/ssh/sshd_config.d/*.conf for top, and na the first value wey e find for one setting e go 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 e no print anything when e valid. If you skip am, one typo fit make sshd fail when e reload. Leave your working session open and test from second connection before you close anything, because wrong key go give you Permission denied (publickey). now and, since passwords don off, no fallback dey. Recovery path for that point na your provider's console.
Give every device e own key. If phone loss, na to delete one line from ~/.ssh/authorized_keys, and your laptop go still dey work. If na one shared key, you go need change the key for every device wey you get.
If you move SSH go another port for Ubuntu 24.04, note say listener dey belong to ssh.socket, so Port line alone 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 no add much security once passwords don off, because system no fit accept guessed password at all. Wetin e add na quiet logs, so real login attempt go easy to notice.
The stronger option na to keep SSH off public internet. Put server behind WireGuard VPN wey you host yourself, bring the tunnel up for phone whenever you need am, and give sshd ListenAddress for tunnel only. mosh dey work over the tunnel because both sides na UDP. One thing to note: tunnel dey add packet overhead, so if large transfers dey stall, lower the MTU (maximum transmission unit) for the phone's WireGuard config.
One last point about this way of working. From phone, you dey approve permission prompts for screen wey dey show small number of diff lines at a time. That na reason to keep the guardrails, no be to off dem. How to run Claude Code safely for VPS cover the user and directory limits wey make sense to set before touchscreen become your main way to enter.
When you reattach and something dey wrong
tmux attach dey print no server running on /tmp/tmux-1000/default mean say the tmux server don disappear, and almost always na because the machine reboot. Check am with uptime. Kernel updates from automatic security updates fit reboot the box, and box wey reboot no get tmux session, so treat any Claude Code run as something wey you fit start again.
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 you see ordinary shell prompt where Claude Code dey before, the process end but the session no end. Check dmesg -T | tail for line like Out of memory: Killed process 4821 (claude). Na wetin box wey dey below the 4 GB requirement dey do during big edit. If no such line dey, Claude Code exit by itself, and the shell scrollback above the prompt get the reason.
If window come back very small, with empty space around am, e mean say two clients dey attached with different sizes, because tmux sizes window to fit the smallest attached client. Your laptop still dey hold the session at 200 columns wide while the phone dey ask for 40. Detach the other clients as you attach: tmux attach -d -t claude.
FAQ
I fit run Claude Code for phone itself instead of for VPS?
No. The platforms wey dey supported 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 for that list. Phone dey also put im apps to sleep and dey change network address constantly. Long agent run no fit tolerate that. Run am for server and use phone as display.
The session go continue if I close app or lose signal?
Yes, and two separate things dey handle am. tmux keeps the process running for server, so nothing go stop when connection end. mosh keeps the connection itself alive across 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 and then show nothing?
If login succeeds and then hangs 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. For most panels, na separate control be that. If mosh instead reports say mosh-server no dey found, server no get the package: sudo apt install mosh.
How I fit interrupt Claude Code with keyboard wey no get Esc key?
Add one key row. Termux configures one with extra-keys inside ~/.termux/termux.properties, and Termius and Blink both come with row wey you fit edit for settings. Esc interrupts response wey dey run and keeps the work wey e don already do. Ctrl+C also interrupts, but if you press am twice for idle prompt, 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. That na reasonable risk for machine wey you fit rebuild. 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.