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.

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
April 8th, 2007 at 7:37 pm
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
April 17th, 2007 at 12:20 pm
[...] Tunneling iTunes shares over SSH. Port 3689, for future reference [...]
April 19th, 2007 at 11:58 am
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…
April 21st, 2007 at 2:33 am
Thanks man, worked right away :)
April 25th, 2007 at 6:43 pm
[...] Tunnelling music from Ubuntu to iTunes via SSH at mrblack.co.uk weblog (tags: ubuntu linux itunes music tutorial) [...]
April 30th, 2007 at 12:30 pm
[...] 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: [...]
May 4th, 2007 at 6:18 am
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?
May 8th, 2007 at 9:51 pm
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 :)
August 27th, 2007 at 12:32 pm
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 :)
August 28th, 2007 at 12:15 pm
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.
September 10th, 2007 at 4:38 pm
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.
September 10th, 2007 at 10:54 pm
I guess I should spell localhost correctly!
October 11th, 2007 at 11:01 am
[...] auf diesem HowTo, via: mobile [...]
November 23rd, 2007 at 6:25 am
Great instructions! Thank you for taking the time to make them so detailed!
James
April 6th, 2008 at 5:07 pm
[...] Source: mrblack.co.uk weblog [...]
April 16th, 2008 at 5:37 am
[...] Tunnelling music from Ubuntu to iTunes via SSH (tags: music ubuntu linux) [...]
October 23rd, 2008 at 8:04 am
[...] Klingt nach einer grundlegenden Anforderung, mit der ich sicher nicht allein bin, was sich auch bestätigen [...]