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.
Source: mrblack.co.uk weblog
