0

I have RaspberryPi which connected to Android Phone via USB and USB Tethering is up. Android Phone is connected to Home Router (Wi-Fi). With this setup, my Raspberry Pi can reach the internet with USB-Android Phone-Home Router-Internet path. And I can reach my Raspberry with VX ConnectBot app in Android Phone. What I want to do is, I want to make ssh connection to Raspberry Pi with my laptop (which is also connected to Home Router). IS it possible to redirect incoming wi-fi packets to usb on Android phone?

To be clear, here is the path that I want;

Laptop (ssh connection) -> Home Router -> Android Phone -> USB -> Raspberry Pi

  • Try running a proxy on the phone and then ssh to the Pi through the phone proxy using the IP address of the Raspberry Pi – AguThadeus May 12 '17 at 9:29
1

That should be possible and requires a reverse port forward, which can be setup with adb:

Run this command on your Raspberry Pi: adb reverse tcp:<remote> tcp:<local> where <remote> is the TCP port on your android phone and <local> the TCP port on your Raspberry Pi.

Example:

adb reverse tcp:2222 tcp:22

Let's say your Android phone has the WiFi IP 192.168.1.5. Now you should be able to connect from your laptop (or any device on the WiFi) to 192.168.1.5:2222 and end up port-forwarded to your Raspberry Pi's ssh on port 22.

You might need to build adb for Raspbian yourself, which is explained here. But recent Raspbian versions should include a recend adb client.

2nd option: you could forward (relay) the ports at the USB tethering subnet - usually 192.168.42.x, where 192.168.42.129 is your Android phone and the Raspberry Pi will have an interface usb0 with the IP address assigned by the Android's DHCP. Understand that once USB tethering is enabled, your phone will have two active network interfaces: wlan0 (which is your WiFi 192.168.1.x as usual) and usb0 (which is 192.168.42.x). You need to know the usb0 IP on your Raspberry Pi, once it's connected to USB tethering. Now to make it all work you would need to use a tool like tcpxd on your Android phone:

tcpxd 192.168.1.5:2222 192.168.42.55:22

Where 192.168.42.55 is your usb0 IP from your Raspberry Pi. Same as option 1: You should be able to connect from your laptop (or any device on the WiFi) to 192.168.1.5:2222 and end up port-forwarded (relayed) to your Raspberry Pi's ssh on port 22.

Both solutions should work without root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.