Includes setup commands, illustrative terminal screenshots, MacBook SSH access, file hosting, scheduled tasks, security and troubleshooting.
1. What You Will Build
This guide turns an Android phone into a small server that can run while connected to Wi-Fi and power. You will install Termux, set up SSH access from a MacBook, run a Python file server, and optionally configure basic scheduled tasks.
Important: these screenshots are illustrative terminal mockups showing the expected commands and example output. Your username, IP address, package output, and Android menus will differ.
What you need
Android 7 or newer is the practical baseline for current Termux packages; newer is preferable.
A MacBook running macOS (the SSH client steps also work on Linux).
Phone and laptop on the same trusted Wi-Fi network.
A phone that can remain plugged in safely with adequate ventilation.
Do not use this setup as your only copy of important files.
How the connection works
MacBook Terminal → Wi-Fi/LAN → OpenSSH server inside Termux on the Android phone. Python's built-in HTTP server can separately expose a folder to other devices on the same network.
2. Install Termux safely
Use the official Termux project page or its F-Droid listing. Avoid old or unofficial APK download sites. If you install Termux and later want a Termux add-on such as Termux:Boot, install both from the same source because builds from different sources may use different signing keys.
Official sources:
Termux GitHub: https://github.com/termux/termux-app
Termux on F-Droid: https://f-droid.org/packages/com.termux/
Open the official link on the Android phone.
Install Termux and approve Android's install prompt if required.
Open Termux and wait for its initial setup to finish.
If an older Play Store build is already installed and package commands fail, back up anything important before changing sources; uninstalling can delete Termux data.
3. Update Termux and install the tools
Run the following in the Termux terminal on the phone:
pkg update && pkg upgrade -y
pkg install openssh python nano curl iproute2 -y
What these packages do:
openssh: provides ssh and sshd for remote terminal access.
python: runs Python scripts and the simple HTTP file server.
nano: beginner-friendly text editor.
curl: downloads and tests URLs.
iproute2: provides the ip command to inspect network interfaces.
Illustrative screenshot: update Termux and install the packages.
4. Enable SSH login
Termux's OpenSSH server commonly listens on port 8022, not the standard Linux SSH port 22.
Create a password for your Termux user:
passwd
Enter a strong password twice. The terminal will not show the characters as you type. Do not paste or share the password in a public document.
Illustrative screenshot: password input is hidden.
Find your Termux username:
whoami
Write down the exact output. It may look like u0_a123, but yours will be different.
Start the SSH server:
sshd
The command may return without a success message. That is normal. To check that the process exists, run:
pgrep -a sshd
Illustrative screenshot: the SSH daemon is started.
5. Find your phone's local IP address
Run this in Termux:
ip addr show wlan0
Look for an IPv4 line beginning with inet, such as 192.168.1.42/24. Use only the IP part before the slash. This is an example address, not your phone's real address.
If wlan0 does not show an address, open Android Settings → Wi-Fi → the connected network → Network details, and look for IP address. Menu names differ by manufacturer.
Illustrative screenshot: identify the phone's actual LAN IP.
6. Connect from your MacBook
Keep the phone awake and connected to the same Wi-Fi. On the MacBook, open Applications → Utilities → Terminal. Replace PHONE_USERNAME and PHONE_IP with the values from your phone:
ssh -p 8022 PHONE_USERNAME@PHONE_IP
Example format only:
ssh -p 8022 [email protected]
On the first connection, check that the address is your phone. If it is, type yes to trust its SSH host key.
Enter the password you created using passwd.
After login, you should see a Termux shell prompt. Commands you type now run on the phone, even though you are typing on your MacBook.
Illustrative screenshot: first-time SSH connection from macOS.
To disconnect, type exit. To reconnect later, start sshd again on the phone if it is not running, then repeat the SSH command.
7. Host files over Wi-Fi with Python
This creates a simple read-only-style directory listing and download server for files in one folder. Do not use it to expose your entire phone storage.
mkdir -p ~/shared
cd ~/shared
Put a test file in the folder:
echo 'Hello from my Android server' > hello.txt
Start the server:
python -m http.server 8080 --bind 0.0.0.0
Illustrative screenshot: Python is serving the shared folder.
On your MacBook or another device on the same Wi-Fi, open a browser and visit:
Replace PHONE_IP with the actual phone IP. You should see hello.txt. Click it to download. The server stays active only while that command is running; press Ctrl+C in that terminal to stop it.
Security warning: Python's basic HTTP server has no login or HTTPS. Anyone who can reach that port on your network may be able to list and download files in the served folder. Use it only on a trusted network, share a dedicated folder containing non-sensitive files, and stop it when finished. Do not port-forward port 8080 to the public internet.
8. Run a Python script
Create a simple script:
cd ~
nano hello_server.py
Paste this code into nano:
from datetime import datetime\nprint('Android Termux task started at', datetime.now().isoformat())
Save in nano: press Ctrl+O, Enter, then Ctrl+X. Run it:
python ~/hello_server.py
9. Optional: schedule a lightweight task
A cron scheduler can run simple recurring tasks, but Android may suspend or kill background processes. A cron entry is not a guarantee of exact timing, particularly when the phone sleeps or the manufacturer applies aggressive battery management.
pkg install cronie -y
Start the cron daemon:
crond
Open the crontab editor:
crontab -e
Add this example line to append a timestamp every 30 minutes:
*/30 * * * * date >> $HOME/heartbeat.log
Illustrative screenshot: an example cron entry.
Save and exit the editor. After some time, inspect the log:
cat ~/heartbeat.log
If nano opens, save with Ctrl+O, Enter, then Ctrl+X. To remove the example job, run crontab -e and delete that line.
10. Keep the server running more reliably
Android is designed to manage battery and background work, so a phone is not as reliable as a dedicated server. These steps can help but cannot guarantee 24/7 uptime:
Android Settings → Apps → Termux → Battery: allow background activity or select Unrestricted if available.
Keep the phone connected to reliable Wi-Fi and power; keep it ventilated and avoid heat buildup.
In Termux, run termux-wake-lock if you need to prevent deep sleep during a session. Install the package that provides this command if it is missing.
Keep Termux open in the background and check the server after Android or Wi-Fi restarts.
Some Android versions may still kill processes; the official Termux project documents background-process limitations.
11. Optional: start SSH after reboot with Termux:Boot
Only do this after manual SSH works. Termux:Boot can run scripts after the phone reboots, but it must be installed from the same source/signing family as Termux.
Install Termux:Boot from the same source as Termux.
Open Termux:Boot once by tapping its app icon.
In Termux, create its boot-script folder:
mkdir -p ~/.termux/boot
Create a startup script:
nano ~/.termux/boot/start-sshd
Paste the following:
#!/data/data/com.termux/files/usr/bin/sh\ntermux-wake-lock\nsshd
Save and exit, then make the script executable:
chmod +x ~/.termux/boot/start-sshd
Reboot and test SSH. Android battery settings may still prevent reliable background operation. Review the official Termux:Boot instructions before relying on it.
12. Security checklist
Use a strong, unique Termux password; never publish it in a guide or screenshot.
Keep SSH reachable only from trusted networks. Do not configure router port forwarding for port 8022.
Do not expose the Python HTTP server to the public internet.
Do not store API keys, passwords, or private client files in a publicly served folder.
Use a dedicated shared folder, not your home directory or full phone storage.
For access away from home, use a properly configured VPN such as a private mesh VPN rather than opening ports on the router.
Update Termux packages periodically with pkg update && pkg upgrade.
Back up important data somewhere other than the phone. A phone server is not a backup by itself.
13. Troubleshooting
Connection timed out: Confirm both devices are on the same Wi-Fi, check the phone's current IP, keep Termux awake, and run sshd again.
Connection refused: The SSH daemon may not be running. In Termux, run sshd; then retry port 8022.
Permission denied: Check the username from whoami and reset the password with passwd.
Phone IP changed: Find the new address and update your SSH command. You can configure a DHCP reservation in your router if you know how.
Python page will not load: Confirm the Python server is still running, use the correct port 8080, and verify both devices are on the same trusted network.
pkg command fails: Run pkg update; if repository errors persist, follow the official Termux package-management troubleshooting page. Avoid old Play Store builds.
Server stops when screen turns off: Review battery optimization settings, use termux-wake-lock when appropriate, and check device-specific background restrictions. Some Android builds still terminate processes.
14. What about OpenClaw agents?
Do not assume the standard Termux + Python + OpenSSH setup automatically supports OpenClaw. OpenClaw has separate runtime, dependency, memory, and model/API requirements. The official OpenClaw Android documentation describes the Android app as a companion node that requires a Gateway running on a supported host such as macOS, Linux, or Windows via WSL2.
If your goal is to run the actual OpenClaw Gateway on the phone, treat that as an advanced, separate experiment and use a clearly reviewed installation path. Community projects may offer unofficial Android/Termux approaches, but they are not the same as official platform support. Do not run an unfamiliar curl | bash installer on a device containing private data without reviewing the source and understanding its permissions.
15. Quick reference: commands to remember
Update packages: pkg update && pkg upgrade -y
Install core tools: pkg install openssh python nano curl iproute2 -y
Show username: whoami
Set password: passwd
Start SSH: sshd
Check SSH process: pgrep -a sshd
Find Wi-Fi IP: ip addr show wlan0
Connect from Mac: ssh -p 8022 USERNAME@PHONE_IP
Start file server: cd ~/shared && python -m http.server 8080 --bind 0.0.0.0
Stop a foreground server: Ctrl+C
Disconnect SSH: exit
16. Official references
Termux app and installation instructions: https://github.com/termux/termux-app
Termux on F-Droid: https://f-droid.org/packages/com.termux/
Termux package management: https://github.com/termux/termux-packages/wiki/Package-management
Termux:Boot official repository and usage: https://github.com/termux/termux-boot
OpenClaw official Android documentation: https://docs.openclaw.ai/platforms/android
Python http.server documentation: https://docs.python.org/3/library/http.server.html
OpenSSH manual pages: https://www.openssh.com/manual.html
Want the members-only resources too?
A free account unlocks them all, including the ones shared in DMs.

