Tunnelling music from Ubuntu to iTunes via SSH

I would love to have a single place where all my music and videos are stored rather than having a bunch of stuff hanging around on laptops, PCs and iPods. So I bit the bullet and began Le Grande Media Server project.

First thing I wanted to do was to set up a music server, so this post is basically stage one. Now, as specs go, we all use iTunes at home and I use it at work, so ideally my music should be served to that piece of software. That about it for specs..

The server I’ll be using is my old desktop running a P4, 512mb ram and about 130gig of hard drive space. Of cause I could throw more hard drives in if need be. This is more than enough power for this task, but meh it was just sitting there.

Step 1 : Install Ubuntu
I chose to install the latest beta of Ubuntu, feisty fawn, as I was rather eager but I’m sure all this will work with Dapper Drake. Feisty really is an impressive operating system, much better than the XP it replaces on my old machine, and, thankfully, makes this task relatively simple.

Installation is pretty straight forward, and documented best over at www.ubuntu.com/

Step 2 : Install mt-daapd
iTunes uses Digital Audio Access Protocol (DAAP) to share content. Now this is ideal for us, as some clever chaps have reverse engineered the protocol and made mt-daapd, an open program that uses this protocol to share a media directory to our local network. So in theory our little Linux box can be seen by any copy of iTunes on our local network.

First of all install ID3 tag support (so mt-daapd can read mp3 files)

sudo apt-get install libid3tag0

Then for mt-daap itself. Its best to grab the latest debian package rather than apt-get to be sure of a working copy (iTunes changes so often).

wget http://prdownloads.sourceforge.net/mt-daapd/mt-daapd_0.2.4-1_i386.deb?download

and then install it

sudo dpkg -i mt-daapd_0.2.4-1_i386.deb

Then, once installed, you need to edit /etc/mt-daapd.conf with whatever you use (vi, nano, gedit, I don’t care). Within this file, point the server to your media directory then restart mt-daapd.

sudo /etc/init.d/mt-daapd restart

Now on another machine you should see your share appear in iTunes and will be able to play music! If not, check to see your Ubuntu box has tcp port 3689 and udp port 5959 open and that iTunes is actually listening for shared music.

Thats sorted me and my family out at home. Hurrah.

Step 3: But I wanna listen at work! *throws tantrum*
DAAP was never supposed to work over the internet. There is a way though, and below are instructions on how I did it for a mac. For windows, it will be possible with putty, but I’m not sure how to complete the entire process.

However, for Ubuntu make sure ssh is installed on your server.

sudo apt-get install ssh

Once thats out of the way check to see if port 22 (the ssh port) is open on your Ubuntu box’s firewall (firestarter is a nice tool for this). Now we want to be able to get to this port from outside our network for that on-the-go-music-server-accessness. So set up port 22 to forward to your server on your modem/router.

If all goes well you should be able to type the following on your Mac and get to your Ubuntu server.

ssh your_user_name@your_external_ip

If not, check your router/modem firewall (or that your pipes aren’t clogged) .

Now we want to set up the tunnel between the server and your shinny mac so the music can flow to you as if you were on your home network.

ssh your_user_name@your_external_ip -L 3689:localhost:3689

Once you have put your password in and agreed to accepting keys, the tunnel is now set up. This is not it though, for iTunes to see the share you need to broadcast its presence. To do this I used Network Beacon, which is set up like in this picture.

nb

Once that chap is up and going, you should be able to see your media server in iTunes.

Hope that’s of use. For me its ace, all that music, at work and at home. Bliss.

Reading
I must point out that most of this was thanks to the following so if you are lost visit these.
Matt’s Blog : Setting up mt-daapd on Ubuntu 5.10
Firefly media server
mt-daapd wiki - ssh tunnel
Ubuntu
Firestarter linux firewall
Network Beacon
iTunes

17 Responses to “Tunnelling music from Ubuntu to iTunes via SSH”

  1. Mike N. Says:

    Mr. Black:

    This is a fantastic howto and was exactly what I was looking for. This simply couldn’t be easier and works flawlessly.

    Thanks for taking the time to post this. It really helped a lot.

    Cheers

  2. genehack.org » Blog Archive » tab dump // 20070417 Says:

    [...] Tunneling iTunes shares over SSH. Port 3689, for future reference [...]

  3. meneame.net Says:

    Música desde Ubuntu hasta iTunes por ssh…

    Si lo he entendido bien, la idea es correr en casa un servidor de música que se vea desde el iTunes en tu puesto de trabajo como si fuese otro iTunes con música compartida almacenada en tu misma red, todo gracias a una conexión ssh. Si funciona, impres…

  4. WiLLiE Says:

    Thanks man, worked right away :)

  5. links for 2007-04-13 at toshism Says:

    [...] Tunnelling music from Ubuntu to iTunes via SSH at mrblack.co.uk weblog (tags: ubuntu linux itunes music tutorial) [...]

  6. MobileMacs » Blog Archive » Feuerflug Says:

    [...] den Zugriff von unterwegs aus reicht ein SSH-Tunnel und ein kleiner Bonjour-Hack, einzurichten wie hier beschrieben. Zuhause habe ich einen 6 MBit DSL Anschluss und im Büro eine 4 MBit Standleitung: [...]

  7. Tudor Says:

    This sounds great! I’ll try it when I have my own Le Grande Music Project hardware bought. One question, tho. If I buy music from iTunes store, can I save it to the server for other iTunes players to play? I presume I’d have to authorise each computer, but still, can I copy to the server from iTunes or do I need to convert the music and then copy it to the server some other way?

  8. site admin Says:

    Yeah you are right. It will stream with drm shite intact and you have to authorise each copy of itunes. I would look into stripping DRM from you your tracks if I were you, it feels nicer that way :)

  9. ignacio Says:

    Brilliant!!!
    Great how to and very well explained, thanks a lot.
    I have a little question… I’ve discovered that most of the mp3’s on my server ar poorly tagged. Do you think there is a way of editing the id3 tags from my mac? Or maybe a good alternative on linux that i could use remotely from my mac? Thanks a lot :)

  10. ignacio Says:

    The problem that I have encountered is that when I access the server from my Mac through iTunes, the library never gets refreshed, so it doesn’t reflect the tagging I’ve done on the server’s files and keeps showing files I’ve deleted.
    Do you have experienced the same problem? Have you found a workaround to this?
    I’d be happy to get some expert advise from you. Thanks again for making this public.

  11. theD Says:

    FANTASTIC! Thanks for the how to. I have been able to accomplish everything minus connecting from my office.
    I’m able to telnet to 3689 so I know there is no firewall issues.
    When I connect to the share in iTunes I get the following error from the server:
    channel 3: open failed: administratively prohibited: open failed
    I have added AllowTcpForwarding yes to the ssh_config but that does not seem to help.
    Anyone have any suggestions.
    Thanks.

  12. theD Says:

    I guess I should spell localhost correctly!

  13. iTunes over SSH — instant-thinking.de Says:

    [...] auf diesem HowTo, via: mobile [...]

  14. James Says:

    Great instructions! Thank you for taking the time to make them so detailed!

    James

  15. Tunnelling music from Ubuntu to iTunes via SSH | vTux Tutorials Says:

    [...] Source: mrblack.co.uk weblog [...]

  16. links for 2008-04-16 at they made me do it Says:

    [...] Tunnelling music from Ubuntu to iTunes via SSH (tags: music ubuntu linux) [...]

  17. Globaler Zugriff auf iTunes Bibliothek der Linkstation (NAS) « designest.de Says:

    [...] Klingt nach einer grundlegenden Anforderung, mit der ich sicher nicht allein bin, was sich auch bestätigen [...]

Leave a Reply