5

So I have an Android smartphone (Samsung Galaxy S5) and I would like to figure out if I can connect it over USB to my laptop running Ubuntu and then control the laptop over SSH and USB rather than over SSH and WiFi.

Is it possible and if so how can I do it?

Vesa
  • 336

2 Answers2

6

I don't know how really this question is related with Ubuntu, but it is fun and I will write an answer.


I have a phone with Android 4.4.4 and often use these tools:


How to connect Android device over USB to SSH into a laptop running Ubuntu

1. Open HotSpot app, go to USB tab and enable USB network sharing. We don't need the connected device to use mobile data over USB, but this option will prepare virtual network that we will use.

2. Open Network Discovery app, go to Settings menuDiscoveryDiscover MethodPing/c.... Go back to home screen and tap on Discover. When this process finishes copy the IP of the target network device. There shall be only one device.

enter image description here

enter image description here

3. Open ConnectBot and setup your SSH key if it is needed (tap on the menu in upper right corner).

4. Setup a new connection - use the discovered IP, and tap on + ADD HOST to save.

5. Go back to the ConnectBot home screen, tap on the new connection and use it.

enter image description here

enter image description here


Additionally if your Ubuntu has GUI and properly configured VNC server, you can setup port forwarding for ConnectBot's connection and can use RealVNC Viewer to connect with your desktop. Pocket Bluetooth keyboard and mouse make things really nice.

enter image description here

pa4080
  • 30,621
5

You can use adb reverse, for example direct your phone's port 8080 to laptop's port 22 by adb reverse tcp:8080 tcp:22, then do ssh user@0.0.0.0 -p 8080 from your phone.

I think this is a better solution since no virtual network or IP detecting is needed.