Skip to content

Instantly share code, notes, and snippets.

@shehbajdhillon
Last active February 3, 2026 21:57
Show Gist options
  • Select an option

  • Save shehbajdhillon/2ddcd702ed41fc1fa45bfc0075918c12 to your computer and use it in GitHub Desktop.

Select an option

Save shehbajdhillon/2ddcd702ed41fc1fa45bfc0075918c12 to your computer and use it in GitHub Desktop.
Setup guide for letting AI agents (Claude Code, Cursor, etc.) control your Android remotely via ADB + Tailscale

ADB over Tailscale

Securely connect to Android over the internet using ADB + Tailscale.

You can also copy paste this gist into your agent of choice and have it explain you what to do.

This guide sets up remote ADB access so you can run android-use — an agent skill that lets AI interact with your Android device over ADB.


Setup

Install Tailscale on both devices:

  • Android: Play Store → login → enable VPN → disable battery optimization
  • Ubuntu: curl -fsSL https://tailscale.com/install.sh | sh && sudo tailscale up

Install ADB (Ubuntu): sudo apt install -y adb


Connect

# 1. Enable ADB over TCP (USB required once per reboot)
adb tcpip 5555

# 2. Get Android's Tailscale IP from the app (100.x.y.z)

# 3. Connect from laptop/VPS
adb connect 100.x.y.z:5555

# 4. Accept authorization prompt on Android (check "Always allow")

Verify: adb devices → should show 100.x.y.z:5555 device


Quick Commands

Action Command
Reconnect adb connect <IP>:5555
Switch to USB adb usb
Reset connection adb kill-server && adb tcpip 5555
Screen mirror scrcpy (see below)

Troubleshooting

Error Fix
connection refused Run adb tcpip 5555 on device
unauthorized adb kill-server → reconnect → accept prompt
no route to host Check Tailscale VPN is on, ping the IP

scrcpy (Screen Mirror)

Mirror and control your Android screen from your laptop:

sudo apt install scrcpy
scrcpy --bit-rate 4M --max-size 1024

Security

  • Use Tailscale ACLs to restrict which devices on your network can reach ADB (Admin Console → Access Controls)
  • Enable device key expiry so compromised devices lose access automatically
  • Never expose port 5555 publicly — ADB has no authentication, anyone can connect

Persist TCP Mode (Optional)

  • Rooted: setprop persist.adb.tcp.port 5555
  • Non-rooted: Use Termux + Tasker to run adb tcpip 5555 on boot

Next Steps

Once ADB is connected, you can use android-use to let an AI agent control your device — tap, swipe, type, and navigate apps autonomously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment