📱 Android Home Server
Turn a spare, non-rooted Android phone into an always-on Linux home server and home-automation hub that you (or an AI agent) can control from anywhere.
No Raspberry Pi, no root, no new hardware: an old phone with a cracked screen works fine.
Built by Romit Kumar (@romitkr). See the original post on X. The reference setup is a Samsung Galaxy S21 FE (not rooted), but any Android 11+ phone works.
What you can control
| Thing | How |
|---|---|
| 🐧 Linux shell on the phone | Termux + OpenSSH (ssh -p 8022) |
| 💡 WiZ smart lamps (scenes, on/off, daily schedule) | UDP JSON on port 38899, sent from the phone |
| 📺 Sony Bravia TV (power, volume, input, open apps) | Simple IP Control (TCP 20060) + optional ADB to the TV |
| 📹 Camera apps / any Android app | ADB UI automation (uiautomator dump + input tap) |
| 🔕 Do Not Disturb, screen, settings | ADB shell (cmd notification set_dnd ...) |
| 🤖 AI agent control | Give an agent SSH/ADB access over Tailscale, plus SKILL.md |
Architecture
flowchart LR
subgraph Anywhere
L[Laptop / server / AI agent]
end
subgraph Home LAN
P["Spare Android phone<br/>Termux sshd :8022<br/>ADB over Wi-Fi :5555"]
B1[WiZ bulb 1]
B2[WiZ bulb 2]
TV[Sony Bravia TV]
CAM[Camera apps on the phone]
end
L -->|Tailscale: WireGuard, works behind NAT| P
P -->|UDP 38899| B1
P -->|UDP 38899| B2
P -->|TCP 20060 + ADB 5555| TV
P -->|input tap + uiautomator| CAMThe phone is the only device that needs to be reachable. It sits on your home Wi-Fi, so it can talk to every local device, and Tailscale makes it reachable from anywhere without opening any router ports.
Requirements
- A spare Android phone (Android 11+ for Wireless debugging), kept on a charger
- A Tailscale account (free)
- An always-on "controller" machine for schedules (a laptop, VPS, cloud box, or the phone itself), with
adb,ssh,python3 - Optional: WiZ bulbs, a Sony Bravia (Android/Google TV) or any device with a local API
Quick start
1. Install the apps on the phone
- Termux from F-Droid (the Play Store build is outdated). Optional: Termux:Boot and Termux:API from F-Droid.
- Tailscale from the Play Store. Sign in.
- Install Tailscale on your laptop/controller and sign in with the same account. Note the phone's Tailscale IP or MagicDNS name (
tailscale status).
2. Linux + SSH in Termux
In Termux on the phone:
pkg install -y curl
curl -fsSL https://raw.githubusercontent.com/romit07/android-home-server/main/scripts/termux-setup.sh | bashOr by hand:
pkg update && pkg upgrade -y
pkg install -y openssh python nmap netcat-openbsd iproute2 termux-api
passwd # temporary password for the first login
sshd # SSH server on port 8022
whoami # your Termux username, e.g. u0_aXXXOn your laptop:
ssh-keygen -t ed25519 -f ~/.ssh/android_termux
ssh-copy-id -i ~/.ssh/android_termux -p 8022 <termux-user>@<phone-tailscale-ip>
ssh -i ~/.ssh/android_termux -p 8022 <termux-user>@<phone-tailscale-ip>✅ You now have a Linux shell on the phone from anywhere.
3. ADB over the network (full phone control, no root)
- Settings → About phone → Software information → tap Build number 7 times.
- Developer options → turn on Wireless debugging → Pair device with pairing code.
- On the controller (same Wi-Fi the first time, or over Tailscale):
adb pair <phone-ip>:<pairing-port> # enter the 6-digit code adb connect <phone-ip>:<debug-port> # port shown on the Wireless debugging screen adb tcpip 5555 # fixed port, easier to reach over Tailscale adb connect <phone-tailscale-ip>:5555 adb devices # should show "device", not "offline"/"unauthorized" - Try it:
adb -s <phone-tailscale-ip>:5555 shell input keyevent KEYCODE_WAKEUP adb -s <phone-tailscale-ip>:5555 shell cmd notification set_dnd alarms # DND alarms-only adb -s <phone-tailscale-ip>:5555 shell settings get global zen_mode # 3 = alarms only, 0 = off
⚠️ After a phone reboot,
adb tcpip 5555is lost: re-enable Wireless debugging and repeat step 3.
4. Configure this repo on the controller
git clone https://github.com/romit07/android-home-server && cd android-home-server
cp config.example.env config.env # fill in PHONE_HOST, BULB_MACS, TV_IP ...
./scripts/adb-reconnect.sh # should print "connected: ..."5. Keep it alive 24/7
- Keep the phone plugged in (ideally with a battery-protect / 85% charge limit).
- Settings → Apps → Termux and Tailscale → Battery → Unrestricted (no battery optimisation).
- Termux:
termux-wake-lock(the setup script adds it to~/.bashrcand Termux:Boot). - Tailscale: Settings → Connections → More connection settings → VPN → ⚙️ Tailscale → Always-on VPN.
- Developer options → Stay awake (screen on while charging), or run
scripts/keepawake.shon the phone, which wakes it only while charging and keeps wireless ADB on:adb push scripts/keepawake.sh /data/local/tmp/ adb shell 'nohup sh /data/local/tmp/keepawake.sh >/dev/null 2>&1 &' - Optional, stops Doze from killing the network:
adb shell dumpsys deviceidle disable(re-apply after a reboot).
More detail: docs/setup.md.
Automation examples
# WiZ lamps: every bulb listed in BULB_MACS together
./scripts/lamps.py discover # find bulb IPs by MAC
./scripts/lamps.py day # Daylight 100%
./scripts/lamps.py on # True colours 100%
./scripts/lamps.py night # Night light
./scripts/lamps.py off
./scripts/lamps.py status
# Daily schedule (LAMP_SCHEDULE in config.env), no catch-up
nohup python3 scripts/scheduler.py >/dev/null 2>&1 &
# Sony Bravia
./scripts/tv.sh on | off | status | vol 15 | mute | input hdmi2
./scripts/tv-adb.sh youtube # open YouTube on the TV (ADB to TV via SSH tunnel)
# Phone
./scripts/dnd.sh on | off | status
./scripts/dnd.sh until 23:59 # silence now, auto-off at 23:59
./scripts/ui.sh # list what's on screen (text, buttons, bounds)
./scripts/tap.sh open com.wizconnected.wiz2
./scripts/tap.sh text "Living room"
./scripts/screenshot.sh shot.jpg # check a camera app / UI state| Doc | |
|---|---|
| docs/setup.md | Full setup, keep-alive, reboot checklist |
| docs/wiz-lamps.md | WiZ protocol, scenes, discovery, schedules |
| docs/sony-tv.md | Bravia IP control + opening apps |
| docs/app-automation.md | Driving any app (cameras, WiZ...) with ADB |
| docs/troubleshooting.md | Offline devices, hangs, IP changes |
Let an AI agent run it
Point a coding/desktop agent with shell access at SKILL.md. It contains step-by-step instructions with a verification check after every step, plus the operating commands (lamps, TV, DND, UI automation). Give the agent the SSH key / ADB access only over Tailscale.
Troubleshooting (short)
device offlineor adb hangs →./scripts/adb-reconnect.sh(=adb kill-server+adb connect). Always wrap adb intimeout.- Phone unreachable → check Tailscale on the phone (a "DNS unavailable" warning usually means the phone's Wi-Fi is bad). Tailscale falls back to a DERP relay if a direct connection fails, so it still works, just slower.
- Lamps/TV disappeared → restart the Wi-Fi extender/router; IPs change after power cuts, so discover by MAC (
lamps.py discover). - Everything broke after a reboot → re-enable Wireless debugging,
adb tcpip 5555, restart keepawake, re-apply Doze settings.
Full list: docs/troubleshooting.md.
Security
- Never expose ADB (5555) or SSH (8022) to the internet. ADB = full control of the phone. Keep them reachable only over Tailscale; don't port-forward anything on your router.
- Use SSH keys, then disable password login in
$PREFIX/etc/ssh/sshd_config. - Use Tailscale ACLs so only your controller can reach the phone.
- Use a spare phone with no banking apps / personal accounts on it.
- Keep
config.envout of git (already in.gitignore).
License
MIT © 2026 Romit Kumar