Coincidence? I think not. 🙂
Coincidence? I think not. 🙂
This is the first how-to article that holds your hand step by step to stream music from the iPhone in Ubuntu over Wi-Fi. This will work on other distributions, simply replace apt-get with your package manager of choice.
Requirements:
– 1.02 Firmware iPhone with OpenSSH installed via Installer.app
– Ubuntu, or probably any distribution based on apt-get (such as Debian)
– Wireless Router (ad-hoc connection probably works too, untested)
These instructions were performed on brand new Ubuntu 32-bit installation of Gutsy Gibbon (7.10). They have been found to be complete and accurate. Installing OpenSSH on the iPhone is outlined in other articles available online, simply search for “iPhone jailbreak” and follow instructions, you will need a Windows PC or Mac.
Using two programs called FUSE (Filesystem in Userspace) and sshfs
we can mount the iPhone filesystem in Linux, then configure ssh key pairs so we can connect without needing to sudo or login as root every time we want to sync the phone, then we’ll install beta versions of Libgpod and Rythmbox to end up with something insanely great:
1. Installing FUSE and other needed programs.
On your PC, goto Applications, Accessories, Terminal
Search for gstreamer in add/remove programs and add everything with the name starting with gstreamer, including ubuntu restricted extras.
Note: You can copy-paste every command from this article using CTRL+Shift+V.
sudo apt-get install sshfs
Then, add yourself to the fuse group with this command:
sudo adduser wayne fuse
[Replace wayne with your username]
Re-authenticate using su - wayne
to avoid /dev/fuse errors later on (or reboot). We’ll be leaving this terminal open for the rest of this guide.
2. Setting up Hosts file, Configuring OpenSSH password, and Configuring SSH Key Pairs
This lets you connect to your iPhone without using a password every time.
Turn off auto-lock on your iPhone by going to Settings | General | Auto-Lock | Never
Adding the iPhone to /etc/hosts
Open a terminal, type:
sudo gedit /etc/hosts
Edit the file to look like this, changing 10.0.0.196 to the IP address of your iPhone:
You can find the IP address of your iPhone by either by looking in your wireless router configuration page (now would be an excellent time to make it a static DHCP address) or on the phone by going to Settings | Wi-Fi, then tapping the blue arrow next to the access point.
Save and quit gedit, you’ll be back to the terminal.
In the terminal we’ll generate SSH keys and connect to the iPhone
ssh-keygen -t rsa
Should output something like this:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wayne/.ssh/id_rsa): [ENTER]
Enter passphrase (empty for no passphrase): [ENTER]
Enter same passphrase again: [ENTER]
Your identification has been saved in /home/wayne/.ssh/id_rsa.
Your public key has been saved in /home/wayne/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx wayne@gutsy
wayne@gutsy:~/Desktop$
4. Logging into the iPhone via SSH, Resetting Passwords, and setting up the iPhone SSH Keys.
ssh root@iphone
Don’t worry, if it takes a long time – the first time you connect, it takes about 30 seconds to generate keys on the iPhone.
wayne@gutsy:~/Desktop$ ssh root@iphone
The authenticity of host 'iphone (10.0.0.196)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'iphone,10.0.0.196' (RSA) to the list of known hosts.
root@iphone's password: dottie
[This is the default password]
#
At the # prompt type the following:
passwd root
[Type in the new password twice.]
passwd mobile
[Type in the new password twice.]
Configure SSH keys on the iPhone.
mkdir ~/.ssh <<
[Error that it exists is OK.]
chmod go-w / ~
cp /etc/ssh_config /etc/ssh_config.bak
echo AuthorizedKeysFile .ssh/authorized_keys >> /etc/sshd_config
exit
You should see the following output:
Connection to iphone closed.
wayne@gutsy:~$
5. Configure SSH keys on your Linux PC/
scp ~/.ssh/id_rsa.pub root@iphone:.ssh/authorized_keys
You should see something like this:
root@iphone's password:
[type the new password you setup here]
id_rsa.pub 100% 393 0.4KB/s 00:00
wayne@gutsy:~$
6. Mount your iPhone using sshfs
sudo mkdir /media/iphone/ -m 777
When running sshfs you may receive errors. Common ones are about /dev/fuse – logout, reauthenticate using
su - wayne
, or rebooting is a simple solution (although not needed).
sshfs root@iphone:/var/root/Media /media/iphone/
ln -s /media/iphone/iTunes_Control /media/iphone/iPod_Control
7. Install SVN versions of Rhythmbox and Libgpod
Download the debs here. (Thanks funk for packaging these!)
Extract this file with Archive Manager, then double click on each one and install each package.
After installing all of these, when you open up Rhythmbox via Applications | Sound & Video | Rythmbox
, your iPhone will magically appear in the devices list, and allow you to stream media via wireless. If it’s not working, make sure that you can still browse to /media/iphone
and view files yourself.
To ummount the iPhone:
fusermount -u /media/iphone
To re-mount the iPhone:
sshfs root@iPhone:/var/root/Media /media/iphone/
Did you run into any problems? Comment here and I’ll help you out best I can.
Bonus tip: Mount /var/root/Library/Ringtones
instead and load up on ringtones!
Ever want to browse your iPhones’ filesystem on your Ubuntu machine? Follow these instructions and you’ll have it working in no time flat.
This article assumes your iPhone is “out of jail” and has Installer.app installed. If you have not already gotten this part taken care of, click here for steps you need to follow first.
Bam! You’re in! Now upload ringtones, compile hello world, slice dice and serve http via apache – whatever floats your dingy.
If you aren’t running Ubuntu, it’s time to upgrade. Just kidding. On any other Linux system this is probably going to be as easy (I hope) or gentoo-style (aka difficult and useless frustration). Two utilities you might need are FUSE and SSHFS if you’re going the frustrating route.
Thanks for reading, I’ll be writing about how to get the iPhone talking with Amarok and how to get ringtones uploaded very soon.
This terrific wiki describes in detail the “tried and true” method of manually performing pretty much every step. Unfortunately, the Wine Application Database shows that iTunes has no maintainer, and is rated as “garbage” by most people.
So right there, my article I had planned about unlocking the iPhone using Linux – simply not possible, as of right now. According to Martin Aumueller, a moderator at the iPhone amarok forums,
“If you manage to get it working it won’t be easy at all:
Other than a regular ipod, the iphone does not work as a ‘usb mass storage device’. This means you can’t just mount it as a hard disk. However, it appears that people have managed to hack their iphone so that they are able to install arbitrary software on it, in particular a ssh server. Then it is possible to expose the iphones file system and mount it via fuse as sshfs. On the gtkpod-devel mailing list you could read that the format of the data on the iphone is very similar to an ipod. So they might be able to handle that shortly. As soon as the gtkpod guys have libgpod working with the iphone, you could try to compile Amarok against the updated libgpod and try to get it working.”
So I checked out the libgpod SVN, and found they had a version that worked once you had SSH running on the iPhone – which means it’s kinda pointless to use a Linux box to try and get things unlocked, because to get SSH running, you need Window or Mac, which is confirmed by Eric Betts (who also has a quick guide how to get gtkpod working), a CS major at OSU – go Beavers!
benanzo has some interesting information over at the ModMyiPhone forum:
“Linux users have been able to sync with the iPhone for awhile now. We just mount the iPhone’s FS wirelessly via sshfs, load GTKPod and sync …wirelessly.
The current SVN version of libgpod (the backend that manipulates iTunesDB) has recently implemented full support for artwork, video, calendar, contacts, podcasts etc. for the iPhone, iPT.
You can also use gnupod. In fact, with that I’ve written a script that runs on my phone that checks what wifi network i’m connected to and if it’s my home network (where my computer is) it automatically initiates syncing.
That means that whenever I get home, I don’t have to sit down at my computer, or even take my phone out of my pocket — everything syncs back and forth automatically. Beautiful.
I’m currently in the process of porting libgpod to the iPhone environment so we can integrate over-the-air downloads into iTunesDB. That basically means we can then write a GUI frontend to bashpodder (podcast client) and automatically download/sync podcasts on-the-go.
My next project will be to get internet radio running…
Shoutcast on-the-go will be sweet.”
That’s it from me, for now. Here are a bunch of links that should get you started unlocking your iPhone. I’m going to detail later on how to get the sshfs and libgpod svn working on Ubuntu.
1, 2, 3, 4, 5, and lastly, how to remove the iPhone AT&T SIM card. That threw me for a loop.
So far I’m enjoying the iPhone, it’s a beautiful machine – even better when running on T-Mobile.
Three words, one acronym: Midnight Commander via SSH. Damn, I really am a geek!
There’s two solutions that I’ve found. One is a native client, the other is a web based solution that acts as an SSH proxy.
I’m buying an iPhone tomorrow, and I’ll be demonstrating both solutions, plus any others that I find. I’m going to be trying to get it running on T-Mobile’s data network also, so I’ll have plenty of new material coming up within the next few days. SSH to my Smoothie, my Ubuntu box, and probably even a quick how-to use the VLC web-interface to remote control your PC.
That’s a good one – I’ll be using a glorified iPod to control my PC that’s playing music and movies.
Please subscribe to my RSS Feed on the left if you’d like to be notified when I post new articles.