Can I ssh (into a mobile device) via USB?

I have a tablet with a USB connection to a host computer. (Ideally the host is running Windows, but if absolutely necessary I could switch the host to be Ubuntu also.)

I want to be able to SSH into the device without RS-232, WiFi, or other network connection. What software combination and setup do I need to make this happen?

Basically, I'd love the be able to have the equivalent of adb shell, but for when the tablet is running pure Ubuntu, not Android.

The tablet happens to be running 9.04, but I'd be happy to upgrade it if required.


So, to clarify, you want to connect to your tablet(running Ubuntu) from your PC (running Windows, but could run Ubuntu if it had to) by ssh over a USB connection?

I haven't heard of doing this before but google searches for things like "ssh over USB" let to many hits where people were showing how to connect a jailbroker iphone with OpenSSH installed to a Windows PC using WinSCP or Putty. Here are some links:

iFans - SSH via USB with WinSCP

OpenSSH, USB instead of WiFi

The Ubuntu tablet could easily replace the iphone because it has OpenSSH on it already but I don't know too much about tunneling a SSH connection to USB, except that SSH uses port 22. These two tutorials use a program called itunnel but I don't know anything about it. I went to itunnel's site and it said "iTunnel is a simple Linux command line program which provides SSH tunnelling over the USB cable to a jailbroken iPhone. I wrote this little tool because I got tired of having to SSH into my iPhone over the WiFi link. SSH proxy, ssh link, and scp all work great." Because it says "simple Linux command line program", I think it is at least worth investigating to see if it will work.

This is an interesting prospect and I would like to see where it goes, but I feel connecting through USB makes this considerably more work than it needs to be. I have used the android app Proxoid to connect my phone to my laptop for tethered wireless connections using the ./adb forward tcp:8080 tcp:8080 command but the tunneled connection required me to set the proxy on my browser before I could get online. Tunneling your SSH connection to USB might make it hard for your applications to connect without some extensive messing around with options.

If you have an old router lying around (like a Linksys wireless B or G router) you could just connect the Tablet and PC together using that and SSH into the Tablet without messing around with tunneling.


Just in case you would want to ssh into Android:

Download a cyanogenmod 7 rom and extract dropbear, dropbearkey and dropbearconvert from the /system/xbin/ directory. Dropbear is a lightweight alternative to sshd. Copy them over to the phone, move them to /system/xbin/ and give them the permissions and ownership they had in the archive.

Generate an ssh key for your desktop if you don't have one already: ssh-keygen -t rsa
Copy the public key to the phone: adb push .ssh/id_rsa.pub /sdcard/authorized_keys

Set up your keys on your phone via adb shell:

mkdir /data/dropbear  
chmod 755 /data/dropbear  
mkdir /data/dropbear/.ssh  
chmod 700 /data/dropbear/.ssh  
mv /sdcard/authorized_keys /data/dropbear/.ssh/  
chown root.root /data/dropbear/.ssh/authorized_keys  
chmod 600 /data/dropbear/.ssh/authorized_keys  
dropbearkey -t rsa -f /data/dropbear/dropbear_rsa_host_key  
dropbearkey -t dss -f /data/dropbear/dropbear_dss_host_key 

Run dropbear on your phone in a terminal or using adb shell: dropbear -s -F -v -p 2222

Connect from your desktop: ssh -i .ssh/id_rsa -p 2222 -l root 127.0.0.1