Horny Feed Takeaway

Tuesday 17 January 2006

How to: Share your music via iTunes on the Net

NSFW Reddit!

After much frustration, I've finally set up my new mac mini to stream all my music to my work laptop. I say frustration, because whilst there is plenty of help out there, none of it in itself was complete enough to get me up and running. Some where too mac to mac, some to unix to mac, some unix to windows. Nothing really gave me the step by step, follow this and it will work guide.

So, I present "The definitive guide to setting up iTunes streaming via the internet from a Mac running OSX to your PC running windows". Phew that’s a mouthful.

The Short Guide

  1. Turn iTunes sharing on

  2. Turn on remote login

  3. Open up the Mac firewall on ports 22 & 3689

  4. Forward port 22 on your router to your Mac

  5. Download and install SSHTunnelClient

  6. Setup a SSH Tunnel from your PC to your Mac

  7. Download and install Rendezvous Proxy

  8. Setup an iTunes daap listener

  9. Open up the PC firewall on port 3689

  10. Open iTunes, listen to music over the internet

Essentially what we are going to do, is create a SSH tunnel between the local (windows) and the remote (mac) machines. When then fool the local machine into thinking that the remote machine is local, and whammo we have music.

The Long Guide

  1. Turn iTunes sharing on, so that iTunes can stream music out.
    Open iTunes, go to preferences, go to sharing. Click "Share my music" and choose to share your whole library or only selected playlists, as you like. Give it a name (and a password if you like) and you're good to go.
  2. Turn on remote login, so that we can access the Mac over the internet.
    Go to System Preferences, go to Sharing. Under Services make sure "Remote Login" is checked. This essentially turns on the Macs built in SSH service/daemon, because it's Unix under the hood after all.
  3. Open up the Mac firewall on ports 22 & 3689, so that we don't get rejected accessing the Mac or the iTunes stream.
    Go to System Preferences, go to Sharing. Under Firewall make sure it's either off (highly unadvisable) or that "Remote Login - SSH (22)" and "iTunes Music Sharing (3689)" are checked.
  4. Forward port 22 on your router to your Mac, so that we can get through the NATing most routers do.
    Log onto your router and find the NAT settings. Set up your router to forward any traffic coming in externally on port 22 to go to your Mac. On my router this involves putting in my external IP address (found using whatismyip, port 22, my internal IP (which I've set in the router DHCP not to expire) and port 22. Now if your broadband provider gives you an dynamic non sticky IP address, you'll have to change this when it changes. Also if you're using DHCP internally, either configure you Mac manually with an IP address or configure your router not to expire the Mac's IP address. I'm assuming you're running a DSL or Cable connection and using NAT to connect your machines at home. If not make sure that hitting your home network on port 22 hits the Mac on port 22.
  5. Download and install SSHTunnelClient, so that we can easily create an SSH tunnel. Think of this tunnel as a virtual pipe between the two machines. Now we can either set it up manually using command line applications like putty or plink, or we can install cygwin and run ssh 'natively'. However this is like serious hassle, and I've always preferred a good GUI. Not withstanding some bits of the application being in German, SSHTunnelClient is a very good app. Easy to use and minimizes to the system tray means there is no need to leave messy client applications or command windows open.
  6. Setup a SSH Tunnel from your PC to your Mac, so we can link our machines securely. Using SSHTunnelClient makes this a dream. Click Tunnel, Add, and create a tunnel with the following settings
    • Tunnel Name - iTunes [or whatever you want to call it]
    • SSH Host - xxx.xxx.xxx.xxx [put the IP address of your home Mac here]
    • SSH Port - 22 [i.e. the official SSH port]
    • Local Port3689 [i.e. the iTunes streaming port that iTunes is going to look for locally]
    • Remote Host - 127.0.0.1 [i.e. the tunnel ends locally (127.0.0.1 being localhost) on the remote machine, not bounced onto some further machine]
    • Remote Port - 3689 [i.e. the iTunes streaming port that we are going to connect to on the remote machine]
    • Username - [put your Mac login name here]
    • Save Password - Tick/Untick [Ticking this and putting your password in below means you don’t have to login everytime, but also means anyone who has access to your PC can access your Mac]
    • SSH Key File - Leave blank [You can create key files that do the login and authentication using secure keys without you having to enter a password. I might figure out how to do this sometime but your password is pretty secure in the SSH pipe]
    • Forward - Local to Remote [i.e. poking on the local port forwards us to the remote port]
    • Auto connect - Off [Although if you want it to connect automatically on load set this on]
    • Compression - On [You could turn this off if you want, it wont make any difference to the music I would surmise, but might make the control commands quicker]
    • Do Keep-Alive-Ping - Off [I have this off, if your connection keeps dropping try turn this on]
    • SSH1/SSH2 - SSH2
    That’s it, test the connection and then hit save. Double click the iTunes icon in the SSHTunnelClient box and a little padlock should appear to show we have a connection.

    Drop to dos (Windows Start, Run, cmd) and type "telnet 127.0.0.1 3689". This creates a telnet session to the local machine on port 3689. If our tunnel worked we should be shunted through the virtual pipe to the remote mac, and the screen should go black. Hit enter twice and you should see

    HTTP/1.1 400 Bad Request
    Date: Sat, 12 Mar 2005 21:08:37 GMT
    DAAP-Server: iTunes/4.7.1 (Mac OS X)
    Content-Type: application/x-dmap-tagged
    Content-Length: 0

    This is good, and means we're hitting the iTunes streaming server on the Mac. If you don't get this you have a problem, and you better figure it out, cause there is no point proceeding otherwise.

  7. Download and install Rendezvous Proxy, so that our local iTunes thinks the remote iTunes is local. This is a little Java application that proxies Apples Rendezvous network technology. Without this our local iTunes would have no idea that the remote iTunes exist.

  8. Setup an iTunes daap listener, so that iTunes can see the remote steaming iTunes. Run RendezvousProxy. Click "Add Host", and add one with the following details
    • IP Address - 127.0.0.1 [i.e. look locally (and that’s where it will find the tunnel we set up)]

    • Port - 3689 [i.e. look locally on that port and magically be transported through the tunnel as we proved with our telnet test above]

    • Host Label - iTunes Streaming via SSH Tunnel [or whatever you want to appear in iTunes]

    • Service Text - Leave blank [or whatever 'notes' you want to make]

    • Service Type - _daap._tcp. (iTunes Host) [i.e. The Rendezvous service we are proxying.]

  9. Open up the PC firewall on port 3689, so that we don’t block the incoming stream. If you're running a firewall locally (and if you have XP SP2 you probably are), turn it off. Get the streaming working and then turn it back on. The streaming should fail. Then open up port 3689. If you still have problems try opening up port 5353 (UDP) as well, although I think this is only needed when sharing music from a windows machine.

  10. Open iTunes, listen to music over the internet, so that we can access all our music at home. In iTunes you should see a blue playlist under the green ones for music store and purchased music. Click on it and the system will churn for a while depending on how big your remote playlist is. I'm not sure how much of the full playlist it needs to bring across, but it's a big enough chunk. My playlist is 6.5mb and this takes a minute or two for me, so give it time. If you want to check that it's doing something open up task manger, and click on the networking tab. You should see a whole stack load of activity. After a while the name in the blue playlist should change to the name you set in iTunes in step 1 and a grey arrow should appear next to the name. Clicking the arrow should show you all your playlists, and clicking on a song or a playlist and hitting play should give you music


Other notes

  • Turn of sharing on local machine if you are having problems. I read that this can be an issue on windows. I've also read there are ways to give everyone on your local lan access to the stream via your iTunes, but your on your own figuring that one out.
    • UPDATE - Rendezvous Proxy does this and actually broadcasts the beacon locally, so that others (on your local lan) can see it. Although it wont work with the beacon created above as that points locally (127.0.0.1) and other peoples machines wont have the SSH pipe. I think you need to create another one with your local IP address for this to work. I think. I'm not sure how well this works (so far tests have failed) and remember you only have so much bandwidth

  • If iTunes keeps lossing the connection, directly after retrieving the full list from your remote machine, reboot. Don't know what the problem was, but it worked for me.

  • Remember that you are streaming music. So if you have a 256kb uplink on your DSL and you try streaming a file ripped at 320kb you're going to have a problem. You can try setting your buffer size to be larger, but I don't know what the buffer size is actually so I don't know how much of an effect this will have. I would set the buffer size to be larger anyway (iTunes, Preferences, Advanced, "Streaming Buffer Sized".
    • UPDATE - I have a 256kb connection and anything above 128 needs to constantly rebuffer. I'll be getting a 400kb uplink on thursday so hopefully that will stream better.

  • You can do the same thing running your remote server on unix or windows. On unix you need to set up Multi-Threaded DAAP Daemon and on windows you need to have a SSH server running. Poke around on google for one.


I suspect none of my regular readers will care much about this, but it took me ages to figure out how to do it. So maybe this will help someone else out who arrives via google. Let me know if you find any better way to do this or if it helped. I'm sure there are mistakes in my guide, let me know if you see them

New Notes

  • 09/09 - Apparently there are problems with iTunes 5.0 and sharing. This is because a change to the daap stuff so that Rendezvous Proxy doesn't work with iTunes 5 client. If you want to do this you need to make sure you don't upgrade your client. You can upgrade your server fine. I'm running 5.0 as my server on the mac and 4.9 as my client on windows and that tested fine. If anyone has the solution to using 5.0 as a client, let me know.

  • 30/11 - The same holds true for iTunes 6.0. If you want this to work you need to use iTunes 4.9 as the client. I still can't find a solution, although I believe the MT-DAAPD people have a fix, but Rendezvous Proxy hasn't been updated in like forever. As soon as I have time to poke around and find a solution, I'll let you know.