Run OpenClaw on an Android phone with Termux
This guide assumes you already installed the following from F-Droid:
- Termux
- Termux:API
- Termux:GUI
From here on, the only goal is to get sshd running so you can SSH into the phone from a computer. Once you have a comfortable terminal, you can let a coding agent do the full OpenClaw setup.
You are opening remote access to your phone. Use a strong password (or better: keys), keep it on your local network, and stop sshd when you are done.
1) Install and start OpenSSH in Termux
Open Termux (not Debian/proot). Then run:
pkg update && pkg upgrade -y
pkg install -y opensshStart the SSH server:
sshdCheck that it is listening:
ss -tlnp | grep sshd || netstat -tlnp | grep sshdBy default, Termux’s sshd listens on port 8022 (not 22).
2) Set a password for your Termux user
Termux SSH authenticates against the Termux user. Set a password:
passwd3) Find the phone’s IP address
Make sure the phone and your computer are on the same Wi‑Fi.
In Termux:
ip addr showLook for an address like 192.168.x.x or 10.x.x.x on wlan0.
4) SSH into the phone from your computer
From your computer:
ssh -p 8022 <termux_username>@<phone_ip>Your Termux username is usually whatever you see before the @ in the prompt (often it is something simple like u0_a123). If you are unsure, run this in Termux:
whoamiIf you want a one-liner you can copy/paste
On the phone (Termux):
echo "user=$(whoami) ip=$(ip -4 -o addr show wlan0 | awk '{print $4}' | cut -d/ -f1)"5) (Recommended) Use SSH keys instead of a password
On your computer, generate a key if you do not have one:
ssh-keygen -t ed25519Copy the key to the phone:
ssh-copy-id -p 8022 <termux_username>@<phone_ip>If ssh-copy-id is not available on your computer, you can manually append your public key:
- On your computer:
cat ~/.ssh/id_ed25519.pub - On the phone (over an SSH session):
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cat >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keysPaste the public key, then press Ctrl+D.
6) Keep sshd running
For a quick setup session, you can just leave Termux open and sshd running.
If you want sshd to survive disconnects, run it inside a multiplexer:
pkg install -y tmux
tmux new -s ssh
sshdDetach: Ctrl+b, then d
7) Hand off to a coding agent (OpenClaw setup)
At this point you have a proper remote shell into the phone. Now you can:
- Use your editor from the computer (VS Code Remote SSH, terminal-based workflow, etc.)
- Run a coding agent that will install and configure OpenClaw end-to-end
8) Additional Info for the agent
comes from
When you run openclaw gateway for the first time it will have errors saying it cannot access /tmp/openclaw. OpenClaw REALLY wants to create a directory in /tmp and use it for everything, but because we are on raw termux we do not have access to messaging with the /tmp directory of Android so we will get a lot of failures like that. The trick is to put this at the end of your .bashrc :
export TMPDIR="$PREFIX/tmp" export TMP="$TMPDIR" export TEMP="$TMPDIR"
You also want to make sure to add this to your openclaw.json:
"logging": { "level": "info", "file": "/data/data/com.termux/files/usr/tmp/openclaw/openclaw-YYYY-MM-DD.log" }
Also make sure a temp directory inside the termux route exists so run: mkdir -p /data/data/com.termux/files/usr/tmp/openclaw
After that do a source .bashrc and run openclaw gateway again and it should work.
Next, you can do openclaw onboard and add your model token for whichever model you choose. I recommend using tmux and running the gateway in a tmux session as a way to keep track of it and keep it alive.
Set the gateway.bind property to lan so that the Gateway can run as 0.0.0.0 that way you can hit the Dashboard from the phone's IP address on your local WiFi network.
You probably want to tell OpenClaw it is living inside a termux app on a Android smartphone and that Termux:API and Termux:GUI are installed so it can utilize those things if it needs to for a particular task.
You can also give OpenClaw the ability to write arbitrary things overlayed on top of the screen. Install Termux:GUI app and pkg install termux-gui inside termux and then run the overlay_daemon.py in a new window of the tmux session you have open and then instruct OpenClaw that it can use that daemon to write stuff to the screen for the user to see when needed.