Dienstag, 13. November 2012

The quick way to USB tethering via SSH on your N9

Here's something obvious (and I'm sure it has been discussed before, I just can't find the link right now), but it might be helpful if you haven't played around with SSH much yet, and your Wi-Fi Hotspot isn't working (the case for me right now). The goal is to get an internet connection over your N9/N950 from a PC (tested with Linux, expected to work with OS X and probably also works on Windows - on Windows you might need something like PuTTY).
  1. Enable developer mode on your device
  2. Connect your device to your computer via USB
  3. Select "SDK mode" when asked for the USB connection type
  4. Use the SDK connection utility, and select USB connection
  5. Note the password displayed in the "Connectivity Details" screen
  6. On your computer, use "ssh -D 9898 developer@192.168.2.15"
  7. Accept the host key question, and enter the password from step 5
  8. You should be greeted by a Busybox prompt "/home/developer $" - leave that open in the terminal window in the background
  9. At this point, a SOCKS proxy server is running on port 9898, and you can use it in any applications supporting a SOCKS proxy (there are even utilities like socksify(1) (Debian package: dante-client) that make generic network applications work through a SOCKS proxy)
  10. To use it in Firefox, go to Edit - Preferences - Advanced - Network - Settings..., then choose "Manual proxy configuration" and set "SOCKS Host:" to localhost and port to 9898 (be sure to disable the proxy again when you want to browse via a normal Wi-Fi/Ethernet connection)
Instead of doing steps 4 and 5, you can set up a permanent password for your "user" account on the N9, and even set up a SSH key on the N9 to avoid having to enter the password. You can make step 6 simpler by adding an entry to your ~/.ssh/config file (on your host) - see ssh_config(5) for details:

Host n9proxy
    HostName 192.168.2.15
    User developer
    DynamicForward 9898

After that, a "ssh n9proxy" (possibly followed by the developer password) is all you need to set up the proxy. This method is arguably easier (and definitely safer) than using the Wi-Fi hotspot, and instead of using up battery on your N9, it gets charged via the USB port while you are using it.

By the way: You will have to manually connect your N9 to your mobile internet connection, this won't happen automatically.

2 Kommentare:

thedead1440 hat gesagt…

hi thp,

Do you have any idea how to share the phone's WiFi connection to the PC?

For example for the n900 there is: http://wiki.maemo.org/N900_USB_router

This is useful when using a PC without a wifi card and it allows just connecting the n9 via USB to share the n9's wifi connection over USB.


Thanks,
thedead1440

thp hat gesagt…

thedead1440: This method also works when you connect your N9/N950 to WiFi. It's independent of the "upstream" connection method - as long as you can connect to it from a shell on your N9, when you SSH into it and create a SOCKS proxy, you can connect to the outside world through that proxy. HTH :)