Using real ADB from Termux without root or a PC

Ever wanted to use ADB to control another Android phone but didn't have a PC around? It turns out you can run the real ADB client directly from Termux on your Android phone.

The problem is that connecting two Android phones over USB OTG and making Termux's ADB communicate with the other phone isn't as straightforward as it sounds. Android's USB restrictions make this a bit tricky without root.

That's why I built ADBLink: a small Android app that bridges a USB connection to a local TCP port, allowing the real ADB client running in Termux to communicate with another Android device.

How it works

The idea is simple. Instead of implementing ADB commands inside the app, ADBLink acts as a transport bridge between the USB connection and a local TCP socket.

The architecture looks like this:

Termux (adb client) | | TCP: 127.0.0.1:6000 | ADBLink app | | USB OTG | Target Android phone (adbd) 

ADBLink holds the USB connection to the target phone and forwards raw ADB protocol data between the target's "adbd" and "127.0.0.1:6000".

Termux's own ADB client then connects to that port. As far as ADB is concerned, it is communicating with an ADB endpoint, so you can use your usual commands.

Why port "6000"?

I deliberately chose port "6000" instead of the more familiar "5555".

The stock ADB client probes localhost ports in the "5555–5585" range for emulator instances. Using a port in that range can result in unwanted emulator detection and phantom devices.

Port "6000" sits outside that range, avoiding that particular issue.

RSA authentication is handled by ADB

ADBLink doesn't generate, store, or manage ADB authentication keys.

Authentication happens directly between Termux's ADB client and the target device. When authorization is required, the target phone displays the standard Android USB debugging prompt:

Allow USB debugging?

You can approve the connection just as you would when connecting a phone to a PC. ADBLink simply forwards the protocol traffic; it doesn't replace or bypass ADB's authentication.

Getting started

You'll need:

  • An Android phone with USB OTG support.
  • Termux installed on the host phone.
  • USB debugging enabled on the target phone.
  • An OTG cable or adapter to connect the two phones.
  • ADBLink installed on the host phone.

The host phone doesn't need root.

1. Connect the phones

Enable USB debugging on the target phone and connect it to the host using USB OTG.

Open ADBLink on the host and grant USB permission when prompted. The app runs as a foreground service and attempts to reconnect automatically if the cable disconnects.

2. Install ADB in Termux

Open Termux and run:

pkg install android-tools 

Then restart the ADB server to ensure a clean connection:

adb kill-server 

3. Connect to the relay

Run:

adb connect 127.0.0.1:6000 

Then check the connected devices:

adb devices 

Accept the USB debugging authorization prompt on the target phone if it appears. You can also select "Always allow" if you want to authorize that host in the future.

ADBLink also includes a button to copy the Termux commands, making setup easier.

What can you do with it?

Once connected, you're using the real ADB client from Termux. That means you can use your usual ADB commands, including:

Open a shell:

adb shell 

Transfer files to the target:

adb push file.txt /sdcard/ 

Pull files from the target:

adb pull /sdcard/file.txt . 

Install an APK:

adb install app.apk 

Read logs:

adb logcat 

You can also use other standard ADB commands, such as "reboot", "forward", and more, subject to the target device's permissions and capabilities.

Testing and compatibility

The earlier Java version was tested on a pair of Android phones. The Kotlin version (v3.7) has also been tested by me on a real phone over USB OTG and works.

The project also includes 13 unit tests written in Java and run against the Kotlin implementation. These tests use a simulated ADB target over a local socket rather than physical devices.

That said, real-world device compatibility hasn't been extensively tested yet. Different Android versions, USB controllers, OTG adapters, and manufacturer-specific implementations may behave differently.

I'd appreciate feedback from anyone willing to test it on other devices.

Security considerations

ADB is a powerful debugging interface, so it's worth being careful.

ADBLink exposes a relay on "127.0.0.1:6000" while it's running. Other apps on the host phone may be able to connect to localhost, so you should treat the relay as an exposed ADB endpoint during its active session.

Stop the service when you're done.

Only connect devices you own or have permission to debug, and carefully review the authorization prompt on the target device.

Limitations

  • Only one ADB client connection at a time. A new connection replaces the previous one.
  • Device compatibility hasn't been extensively tested.
  • ADBLink is a transport relay, not a full ADB implementation or a replacement for the ADB client.
  • USB OTG support and behavior may depend on the device and adapter.

Source code and download

The project is open source. Contributions, bug reports, and device compatibility feedback are welcome.

If you try ADBLink, please let me know which devices and Android versions you tested it on, and whether everything worked as expected.

I'd love to see how well it works across different Android devices.