6

Is it possible to connect a rooted Android device to a RPI via USB and then SSH into the RPI from the Android device over the USB connection? If so is there any documents or tutorials out there that outline this? I've done it from wireless several times but I would like to achieve the SSH connection over the USB cable.

11

You could do that, using android's USB tethering. On android 4 this option should be at settings>more>Tethering and portable hotspot>USB tethering (option becomes enabled when you plug the USB to the PI).

Then you need to set up your PI for this:

1) add the following to /etc/network/interfaces:

auto eth0
iface eth0 inet dhcp
iface usb0 inet dchp

2) and execute the following command:

ifup usb0

Confirm your connection is up via ifconfig

Original guide information was taken from here

  • Thanks for the info! I will try this out over the weekend and get back to ya. I want to be able to use my RPI on the fly and keep wireless available to my RPI for other purposes. Thanks! – 0xhughes Jun 7 '13 at 13:03
  • Sorry for the extreme delay! I was succesfully able to implement this! It was really slick, been using it for months! – 0xhughes Dec 31 '13 at 22:20
1

Not all the Android devices support USB tethering. If it's available on you device, go for it. Otherwise, you can use an ADB client installed on the Raspberry PI, then using some port forwarding you can make the Android tablet and the Raspberry Pi talk on USB.

1

@GuySoft answer needs to be updated based on Raspian Jessie from this answer:

DO NOT MODIFY /etc/network/interfaces

Add the following to the end of /etc/dhcpcd.conf

interface usb0
static ip_address=192.168.42.42/24
static routers=192.168.42.1
static domain_name_servers=8.8.8.8

routers and domain_name_servers line may not be necessary

  • 192.168.42.42/24 is NOT in the same subnet as 192.168.44.1 so your network setting WILL NOT WORK. Your RPi at 192.168.42.42 won't be able to find the router at 192.168.44.1. – Dougie Jul 27 at 13:47
  • corrected typo pointed out by @Dougie – MikeF Jul 30 at 18:05
  • This worked for me, although I also had to add this line to /etc/network/interfaces: iface usb0 inet dhcp. – swref 3 hours ago
0

Most likely it's impossible. You'll need "Linux USB Ethernet/RNDIS Gadget" driver installed on Android for that, and I'm pretty sure this driver is not included in the standard Android package.

Using a wireless connection would be much easier.

  • Voted this up, because he is right, but then thought of a way around this. – GuySoft Jun 7 '13 at 11:09
  • No, this posting makes an invalid assumption that there is only one way to do it. – Chris Stratton Nov 19 '15 at 18:18
  • It is possible. I do it all the time with my Pi A+ using Termius on Android. – Tooniis Oct 5 '18 at 12:07
0

You might want to read my answer here. It describes how to connect to ssh using USB tethering and your Pi. Bonus: you can even add android's WiFi hotspot to that solution and connect more devices.

If that's not enough, you can use adb to forward your SSH port with adb forward <local> <remote> and adb reverse <remote> <local>

From my experience, you will need a recent adb build, which you'll have to compile yourself as described in my answer here.

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.