Following my post about iPhone + Linux tethering which used wireless to connect the laptop to the iPhone, I started to encounter a few problems with the solution. The main problem I found with this method was setting up the adhoc wireless network. It ALWAYS seemed a fiddle. So I started looking for a way to use the USB cable to connect the iPhone to the laptop and use that for connectivity. The answer was iTunnel! Here is a quick HOWTO for using it. I have sucessfully run this on Ubuntu 8.10 and 9.04.

Requirements.

A Jailbroken iPhone running SSH.

WARNING: DOING THIS BREAKS YOUR iPHONE WARRANTY AND AGREEMENT WITH YOUR CELL/MOBILE PROVIDER: DO THIS AT YOUR OWN RISK!

Installation.

Download iTunnel from: http://www.cs.toronto.edu/~jingsu/itunnel/itunnel-0.0.5.tgz to your laptop.

Open a shell and type:

tar xvfz itunnel-0.0.5.tgz

mv itunnel-0.0.5 itunnel

Running the tunnel.

Plugin your iPhone via USB cable:

cd ~/itunnel

./itunnel 3023

The first time you run this it may fail and unmount your iPhone’s camera folder. Running it for a second time you should be shown the following in the shell:

get_iPhone() success
- successfully got device
server waiting for ssh connection

In a second shell now run the following command, which SSH’s to the new tunnel and sets up a SOCKS proxy on port 9000 for you:

ssh -D 9000 -p 3023 127.0.0.1

Leave both shells open, whilst you wish to be connected to the internet.

Configure Firefox.

Open Firefox and in the url bar enter:

about:config

Filter for:

network.proxy.socks_remote_dns

Now set its value to true. This allows the iPhone to resolve the DNS for firefox rather than the laptop, as only the iPhone has true internet connectivity to do DNS requests.

Now still in Firefox go to Edit > Preferences. Choose the Advanced section and the Network tab. Now click the Settings button and Select Manual Proxy Configuration. Enter the following

SOCKS Host: 127.0.0.1 Port: 9000

Your now ready to browse the internet from your laptop without fiddling about creating a adhoc wireless network! To close the tunnel just hit CTRL+C in the the iTunnel shell.

by-nc
, ,
Trackback

21 comments untill now

  1. please help, I dont know what to do. Where can I install libiphone from? thanks! Could I use this to SSH into my ubuntu from my iphone over the USB cable? thanks!

    root@sesebuntu:~/Desktop/itunnel# ./itunnel 3023
    ./itunnel: error while loading shared libraries: libiphone.so.0: cannot open shared object file: No such file or directory
    root@sesebuntu:~/Desktop/itunnel#

  2. I just managed to replicate your problem.

    I’ve solved it by installing the iFuse package. Add these lines to your /etc/apt/sources.list

    deb http://ppa.launchpad.net/jonabeck/ppa/ubuntu jaunty main
    deb-src http://ppa.launchpad.net/jonabeck/ppa/ubuntu jaunty main

    Then run:

    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com F0876AC9
    sudo apt-get install ifuse

    You should now be able to run itunel as per instructions. I must of installed this package at some previous point in time hence it didn’t make the instructions. Don’t forget you may need to run itunnel twice to grab the device!

    Hope that helps you get on your way.

    Ric_

  3. ok, thanks a lot man, that kinda helped me ssh into my iphone through the usb cable. but now, how can I ssh into ubuntu FROM my iphone? is that even possible? please, it would be of great help to me, as I need to do a dump of my iphone. Thanks a lot nman!!!

  4. can’t mount iphone
    error initialising camera: -60: could not lock the device

    I have tried three times unplugging my iphone, putting it back, and still I receive this. would you happen to know why?

  5. Not via the USB cable as far as I know. I’ve only every done that over the WiFi.

  6. Don’t unplug in between attempts. Connect the iPhone, run iTunnel, after it fails run it straight away again. Seemed to do the trick for me.

  7. Using Gentoo 64bit I get the Same error running itunnel (can’t find libiphone.so.0) as the first comment. I’ve installed ifuse and both of it’s dependancies (libiphone and libplist) and tried again same error. Is this a 64bit problem?

  8. Ok I found libiphone.so.0 in /usr/lib64 and copied it to /usr/lib32 on a stupid hope, and of course it didn’t work, now itunnel fails with an error saying libiphone.so.0 has a wrong ELF class.

  9. for anyone with the same problem as me, here’s how I fixed it:

    The binary for itunnel is 32bit, so when you download the tgz file and hit ./itunnel it looks for 32bit libraries, hence the error. If you have a 64bit system, and hence installed 64bit iflux and it’s dependancies, you need to compile itunnel as a 64bit binary. Doing this is simple.

    When inside the itunnel directory, where the binary is, type “make clean” without the quotes and it will remove the 32bit crap. Then type “make” and it will compile it 64bit if your system is set up 64bit. Then ./itunnel like before except this time no error! Awesome!

    Thank you so much for this!

  10. Pelase help me!
    When i enter “ssh -D 9000 -p 3023 127.0.0.1″, theres error:
    iman@iman-laptop:~/itunnel$ ssh -D 9000 -p 3023 127.0.0.1
    Could not create directory ‘/home/iman/.ssh’.
    The authenticity of host ‘[127.0.0.1]:3023 ([127.0.0.1]:3023)’ can’t be established.
    RSA key fingerprint is df:da:ae:04:d2:5f:51:e5:f7:e0:32:71:1e:e7:e0:5d.
    Are you sure you want to continue connecting (yes/no)? yes
    Failed to add the host to the list of known hosts (/home/iman/.ssh/known_hosts).
    iman@127.0.0.1′s password:
    Permission denied, please try again.
    iman@127.0.0.1′s password:

    Im running iPhone 3.0

  11. Iman try using the root or mobile user to log into the phone. SSH will use your default user name to try and log in which doesn’t exist on the iPhone.

    ssh -D 9000 -p 3023 root@127.0.0.1

    or

    ssh -D 9000 -p 3023 mobile@127.0.0.1

    the default passwords are in the jail break documentation.

  12. I manage to log into root using default password.
    Here’s the result:
    iman@iman-laptop:~/itunnel$ ssh -D 9000 -p 3023 root@127.0.0.1
    Could not create directory ‘/home/iman/.ssh’.
    The authenticity of host ‘[127.0.0.1]:3023 ([127.0.0.1]:3023)’ can’t be established.
    RSA key fingerprint is df:da:ae:04:d2:5f:51:e5:f7:e0:32:71:1e:e7:e0:5d.
    Are you sure you want to continue connecting (yes/no)? yes
    Failed to add the host to the list of known hosts (/home/iman/.ssh/known_hosts).
    root@127.0.0.1′s password:
    Imanz:~ root#

    But I still can’t access the internet.

  13. Thanks a lot for your instructions. After installing ifuse I got rid of the “./itunnel: error while loading shared libraries: libiphone.so.0: cannot open shared object file: No such file or directory” error message. But I’m still unable to conntect my iPhone 3G S (can this new iphone be the problem?) with my notebook. Unbutu 9.04 can find it without any problem… I tried to run itunnel a few times, but I allways get this error message: “./itunnel 3023 – iphone get device error: -3 ERROR: failed to connect to iphone. quitting. quit ok.”

  14. Blankster not sure on the status of the 3GS but have you successfully jail broken the device and installed SSH on it?

  15. @Ric: Thanks for your answer. Off curse I’ve jailbroken my iPhone 3G S and it works like a charm with anything else (copying files from/to it via SSH) from Linux and Windows. I’m not sure if Apple changed something with the usb protocol.. Because I don’t have any Bluetooth adapter on my notebook (and doen’t want to use an usb one) I’m searching for a solution via USB. If I can provide some more information, please let me know!

  16. @Blankster, @All
    I also have troubles with the 3GS:
    $ ./itunnel
    - iphone get device error: -3
    ERROR: failed to connect to iphone. quitting.
    quit ok.

    I’ve contacted the author of itunnel and he said that he will work on a fix.

  17. We’ve been doing some testing in the office and it’s looking like a 3.0 firmware problem. Fingers crossed the itunnel guys fix it.

    Ric

  18. I hope so too… Thanks for testing so it’s not only a problem of my notebook. At least one good thing… But do you don’t think it’s an ifuse problem because itunnel uses it’s libiphone?

  19. Definitely 3.0 firmware problem god apple are so annoying,if only there was a different phone worth having.Why do they hate linux users so much?

  20. Hey what kind of speeds are you guys getting (the ones who get it to work) is it as fast as your 3g network (ex. 1 mbps) or alot slower and what are the speeds like over adhoc network???

  21. I can get everything to work except right at the end in my second terminal (the one i ssh’d through) i get the following

    [code]
    alex@alex-laptop:~$ sudo ssh -D 9000 -p 3023 127.0.0.1
    [sudo] password for alex:
    The authenticity of host '[127.0.0.1]:3023 ([127.0.0.1]:3023)' can't be established.
    RSA key fingerprint is f2:91:10:b9:73:f0:fd:7a:31:8c:64:6d:89:36:eb:41.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[127.0.0.1]:3023' (RSA) to the list of known hosts.
    root@127.0.0.1's password:
    Permission denied, please try again.
    root@127.0.0.1's password:
    Banana:~ root# channel 3: open failed: administratively prohibited: open failed
    channel 3: open failed: administratively prohibited: open failed
    channel 3: open failed: administratively prohibited: open failed
    [/code]

    and it keeps putting that up every time I try to open a web page… I used alpine as the password

You are protected by wp-dephorm:
Private