WHAT'S NEW?
Loading...

How to Access Termux Linux Android via SSH over USB

How to Access Termux Linux Android via USB? You must create port forwarding via ADB. This means that you can map a local port on your computer to a port on your Android device. Then you can open the 8022 port to access Termux via SSH over USB.

Here is how you do it

1. You need ADB

Most operating systems have an ADB package. On my one I was simply able to install it with:
sudo apt install adb
For Windows there is an easy installer available here.

2. Create your port forward

This part is really simple as well, and that's key. I don't want to do 500 things every time I want to connect to my phone.
adb forward tcp:8022 tcp:8022
This is really all it takes. The first instance of tcp:8022 is the local port you want to bind the remote port to. The second one is the port from your Android device. Because Termux' SSHD runs on port 8022 by default, this is what you want.

3. Connect to it

Now that your local port is bound to your Android device you can simply connect to localhost on your computer:
ssh localhost -p 8022
#This is were you put the local port
#(ie. the first one)
This will connect you to your SSH Server. If you haven't set this up yet read this.
You will need to rund the adb commnd after every restart or after you've unplugged your device. I set up an alias for myself for the following command sequence:
adb forward tcp:8022 tcp:8022 && adb forward tcp:8080 tcp:8080&& ssh localhost -p 8022
# This will also setup the port 8080, which is used by the httpd webserver on termux

0 comments:

Post a Comment