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:

screenshot-tokyo-ska-paradise-orchestra-loverswalk.png

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:

iPhone Host File Setup

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!



Are you interested in FREE SUBSCRIPTIONS for qualified professionals to eWeek, PC Magazine, PC World, and many more? Click here!

Tags: , ,


32 Comments to “How To: Stream Music From The iPhone In Ubuntu”

  1. Wayne | October 10th, 2007 at 4:28 am

    Resources and Thanks: Extrapepperoni: SSH on iPhone, HOWTO: Setup ssh keys, funk’s corner of the interschnitzel: Ubuntu & The iPod Nano, and finally Eric Betts.

  2. Blog Feeds about Music » Archive » How To: Stream Music From The iPhone In Ubuntu | October 10th, 2007 at 4:52 am

    [...] You can read the rest of this blog post by going to the original source, here [...]

  3. tyce | October 11th, 2007 at 1:02 pm

    Now I just wish you could stream content the other direction, ie: to the iphone.

  4. The How To Do Things Blog | October 11th, 2007 at 1:45 pm

    How To Stream Music From iPhone In Ubuntu…

    Do you still feel that if you use Ubuntu as your primary operating system you won’t be able to use the cool gadgets and software that you are so accustomed to using? Well you need a rethink. This step by step tutorial teaches you how to stream mu…

  5. meehawl | October 11th, 2007 at 6:18 pm

    I stream music and videos from my server over TCP/IP to my Windows phone using Orb or VLC. EVDO usually gets between 800 Kbps and 1.5 Mbps over the Verizon/Sprint public network.

  6. brian | October 11th, 2007 at 7:42 pm

    Tyce–check this out:
    http://pixelcity.com/iphone-streaming-music/
    It was written to share an iTunes library in OS X (with the folder structure Artists->Albums->Songs) but it could easily be modified to work with any folder structure. It’s just a few dozen lines of PHP. It’s just a plain web thing so if you’ve got your server open to the outside world, you can listed to your music from anywhere. Even works over EDGE, if you’re lucky. :-)

  7. dakira | October 13th, 2007 at 1:13 pm

    regarding step 5.. ever heard of ssh-copy-id? The step would then look like this:
    ssh-copy-id root@iphone

    This command handles the creation of directories and the authorized_hosts file automatically.

  8. How To: Stream Music From The iPhone In Ubuntu w/ Rhythmbox « Song Lyrics | October 21st, 2007 at 5:01 am

    [...] read more | digg story [...]

  9. hokus | November 7th, 2007 at 2:18 pm

    I have some problems with point 6. I have an iphone fw 1.1.1
    I can mount my iphone by sshfs but the next step does not work

    when i use sshfs root@iphone:/var/root/Media /media/iphone/

    then i get a message :”fuse: mountpoint is not empty
    fuse: if you are sure this is safe, use the ‘nonempty’ mount option”
    at the next point ln -s /media/iphone/iTunes_Control /media/iphone/iPod_Control
    i get the message ” Too many levels of symbolic links”

  10. Wayne | November 7th, 2007 at 4:54 pm

    I just updated to 1.1.1 myself, I’ll see if I can update the process… I’ll also be checking if syncing with libgpod works yet.

  11. Edson | November 11th, 2007 at 3:16 pm

    Hello

    Ubuntu 7.10 iphone 1.1.1

    root@iphone’s password: dottie [This is the default password]

    iPhone 1.1.1 password: alpine

    —————————————————-

    mount my iphone: Yes

    Rhythmbox: it closes application automaticamente

    Saludos!!!

  12. Ben | November 26th, 2007 at 12:11 am

    After performing these steps my SSH stream is working great, but my ipod is not registering any data.

  13. Efren | November 26th, 2007 at 3:22 pm

    im having the same problem as Ben. i can upload songs onto the ipod touch but they dont show on it. any help?

  14. Simplicity is Clarity » Blog Archive » Nerdy Stuff | December 26th, 2007 at 3:47 pm

    [...] has. I read about a Google Code project that would let you do it from MacOSX, and then I found this, which says it’ll work from Rhythmbox. Despite having absolutely fantastic taste in blog [...]

  15. Vadim | December 26th, 2007 at 4:47 pm

    I have the same problem as hokus it says :”fuse: mountpoint is not empty
    fuse: if you are sure this is safe, use the ‘nonempty’ mount option”
    at the next point ln -s /media/iphone/iTunes_Control /media/iphone/iPod_Control
    i get the message ” Too many levels of symbolic links”

    so can anyone please help me out :) thank u guys so much

  16. Rubix Hacker | January 21st, 2008 at 10:59 am

    You have to go to media/iphone in your file manager and there will be some short cuts to files that don’t exist, just select them and shift+delete them. then try remounting.

    As for copying music on your iphone/ipod touch you have to use Amarok or gtkpod.

    For the ipod-touch after you mount it you have to issue the commands

    “cd /media/iphone/iPod_Control/Device”
    then
    “sudo lsusb -v -d 05ac: | grep iSerial | awk ‘{print $3}’ | cut -b1-16 | xargs printf “FirewireGuid: 0x%sn” > SysInfo”
    (without the first and last quotes)
    then in amarok set it up as an iphone and enjoy wifi transfers!

  17. Edward Ishaq | March 29th, 2008 at 1:17 am

    Man this is the owsomest post about how to sync the iphone with some media player.

    Thank you very much
    edy

  18. Kuro | March 30th, 2008 at 10:40 am

    The only problem till now is when i wanna listen to some music y have on my iphone directly on my computer, it does play the songs, after some minutes it give you back a red circle with a white X next to the song thats in your iphone, but the rest worck perfectly, i can even put some music from PC to te iphone using ubuntu, so thanks for the information

  19. Turn fun | May 7th, 2008 at 4:46 am

    great! thanks for sharing

  20. Sync Your iPhone Wirelessly in Linux [IPhone] · TechBlogger | May 9th, 2008 at 6:35 pm

    [...] you’re going to prove to your Apple device that you’re trustworthy. Pulling from the fsckin w/linux blog’s guide, here’s the basic terminal steps, with the parts you’ll substitute in bold. They look [...]

  21. Javier | May 12th, 2008 at 2:18 pm

    I have ubuntu 64 and the step 7 (Install SVN versions of Rhythmbox and Libgpod ) doesn’t work, where can i find the svn to 64 bits?

  22. tim redfern | May 18th, 2008 at 2:21 am

    comments & corrections -

    -after i deleted the bogus mountpoint and remade it (I had to sudo create it and then chown it) mounting with sshfs worked, I could see the ipod in rhythmbox.

    -when I add music I have to reboot the iphone for it to show up in the ipod app, does anyone have a fix for this?

    -you say to use the passwd command to change passwords, this is lethal! all applications on the iphone quit after a few seconds and the iphone is unusable. took me hours to fix it. can you remove this from the main post…

  23. Vendetta Solutions Notebook » Ubuntu Hardy + wirelessly mounting your ipod touch/iphone | May 18th, 2008 at 4:39 pm

    [...] you’re going to prove to your Apple device that you’re trustworthy. Pulling from the fsckin w/linux blog’s guide, here’s the basic terminal steps, with the parts you’ll substitute in bold. They look [...]

  24. music » Blog Archive » How To: Stream Music From The iPhone In Ubuntu w/ Rhythmbox | August 29th, 2008 at 10:04 pm

    [...] read more | digg story [...]

  25. name | August 31st, 2008 at 5:32 pm

    Good day!,

  26. name | August 31st, 2008 at 9:31 pm

    Hi!,

  27. Bollywood | January 27th, 2009 at 2:56 pm

    good article keep it up :)

  28. Bollywood | February 2nd, 2009 at 11:22 am

    good post

  29. leigh | February 16th, 2009 at 7:30 pm

    Hello, I can’t “see” anything inside the iphone’s Music folder in the Media directory either from Terminal in the phone, not from my Linux laptop in ssh. I thought this post might help me out, so I started following along.

    When I get to Configure SSH keys on the iPhone, I run into a problem. There is no ssh_config file in the etc/ directory. Has this changed in the later versions of the phone’s OS? Any advice?

    Most obliged. All the best, leigh

  30. leigh | February 22nd, 2009 at 9:34 am

    Ah, ok, it’s in it’s own ssh sub-directory. What about an:

    /id_rsa.pub: No such file or directory

    error when configuring ssh keys on the Linux PC? Does anyone know what that is about?

    Best, Leigh

  31. bde | March 24th, 2009 at 7:22 am

    Towards the end of step 4, I think the correct file to modify is /etc/ssh_config instead of /etc/sshd_config:

    echo AuthorizedKeysFile .ssh/authorized_keys >> /etc/ssh_config

  32. vern | May 13th, 2009 at 7:49 pm

    ssh: connect to host iphone port 22: No route to host
    is the answer i get from ssh root@iphone. please help. thanx

Leave a Comment