What is Tethering?
Tethering is the process of connecting one device (the iPhone) to another (your computer) and sharing an Internet connection. Although there are quite a few ways to connect an iPhone or iPod Touch to a computer running Linux, most of them only allow you to transfer files, not share Internet connections or run commands on the iPhone from your computer. This is especially useful if you have a data plan on your iPhone but not on the computer because it allows you to get Internet access on the computer anywhere you can get on the mobile network.
Keep in mind that this method does require a jailbroken iPhone or iPod Touch because it relies on OpenSSH, which is a program you can easily install through Cydia. This means that you will be doing it somewhat at your own risk. Also, if you are going to be using the iPhone's data connection on your computer, make sure that you check the agreement you have with your cell phone company. You are responsible for making sure it's legal.
How to do it?
The only program I know of that allows tethering and SSH tunneling is itunnel. It is free, open source, and fairly easy to setup and use. The download contains a binary (the program) and the source code. The binary is the file labeled itunnel; if you want to be able to run it from the command line just by typing “itunnel”, move it to /usr/bin or /usr/local/bin. It's simple to use, but unfortunately doesn't always work quite right. Just run it on the command line; the output of the command is important to determine when it successfully connects. You might have to run it two or three times to get a connection and might have to unplug your iPhone and plug it back in; the software isn't perfect. You also might have to run itunnel with root access. However, once it gives you the “successfully got device/server waiting for ssh connection” message, you're in luck! You now have a working connection to the iPhone.
The default port for the tunnel is 3023, but if you run itunnel with a port number as its argument, you can change this. After itunnel connects just SSH to port 3023, and you're in! To enable tethering, use the command “ssh -D someportnumber -p 3023 email@example.com” and type in the password you set for the mobile when you set up the iPhone (the default should be “alpine”) then make Firefox use port someportnumber (which you specified above) as a SOCKS proxy. You also need to set up DNS to work right, by typing about:config in the address bar and setting network.proxy.socks_remote_dns=true (just scroll down to the entry and change it.) Don't forget that you've set this; if you want to use some other proxy later, you'll have to change it back.
There is a more in-depth itunnel tutorial provided by the program's maker. Also, keep in mind that you might also need to install something (probably available from Cydia) to allow your iPhone to bridge the connection properly.
What else can we do with this?
Once you have an ssh tunnel up, you're logged into your iPhone! Apt and its associated utilities (apt-get, apt-cache, etc.) are what Cydia really interfaces with. So if you don't want to wait for Cydia to load, try “apt-get upgrade installed” to upgrade your installed programs, “apt-cache search programname” to search for a program, and “apt-get install programname” to install programname. You'll need to run this as root on the iPhone, so remember the root password you set when you jailbroke it (this defaults to “alpine”, but you should really change it), and change users with “su”. If you want, you can find more information on using APT, a packaging tool also used in the Debian Linux distribution.
Although itunnel is an amazing utility, it has quite a few bugs. It only allows you to open one SSH session – though others can be, has to be restarted if the connection breaks, and will occasionally just stop working. That being said, it's an amazing program and I don't know of anything else out there that does the same thing.
If you're not looking for all this functionality or want to review the options, check out this link: iPhone/iPod Touch in Ubuntu.