Remote iTunes Sharing

I keep most of my media – music and photos – on a 250gb external WDC Passport drive. I usually bring it with me when I come in to the office, but I forgot it today. Whoops. So I set about figuring out how to access it remotely.

The Ingredients

iTunes needs two things to access shared music.

  1. A share present on the local network. Which is to say, on one of the networks the machine is directly connnected to.
  2. An entry for that share in Bonjour.

If you lack either of those, it doesn’t work. Fortunately, it’s not hard to trick iTunes into letting you access any share you want. It’s unfortunate, really. If you use Back To My Mac, any Bonjour services – iTunes included – get announced on your local end, but iTunes ignores it because it’s not on the local network.

The Commands

$ ssh -fNL *:36890:127.0.0.1:3689 USER@REMOTE-HOST
$ dns-sd -R "Remote iTunes" _daap._tcp local 36890 &

Breaking it Down

What we’re doing here is pretty straightforward. We use SSH to create a tunnel from the local host to the iTunes share on the remote side. That gives us #1 from our list above. Then we register it with Bonjour, making it visible to iTunes. It works with any host reachable via SSH.

Simple, straightforward, and works far better than the other approaches I’ve tried.

Future Improvements

If you’re a BTMM user, this is somewhat sub-optimal. You already have a secure tunnel to your remote system, and you’re now layering another on top of it. If there were a simple TCP proxy, you could tunnel the connection with much less overhead. I haven’t found a simple proxy which works yet, though, so this remains a future goal.

2008/10/09
Previously On Atomized:

Discussion

[...] on the second computer enter 2 commands in terminal, which i learned from this site [...]

Remotely access iTunes via ssh « Just Your Average Geek
2009/03/02

Any chance of getting slightly more detailed instructions? I’m not necessarily afraid of the terminal, but at the same time, we’re not exactly best friends either.

Zac
2009/11/19

Zac, The commands in the post are pretty much it. Just make sure your remote host has SSH enabled (System Preferences → Sharing → Remote Login), and substitute the username & IP address of the system for the “USER@REMOTE-HOST” in the first command.

If you don’t know your username, you can run “whoami” in the terminal to find out.

You’ll need the public IP of your system; if you plug in a 192.xx or 10.xx address, it won’t work. Visit http://www.whatismyip.com from the remote system, and plug that into the command.

Ian
2009/12/06

How do I undo the second terminal command? I did not enter the first, because I already have back to my mac. Now the external itunes shows, but does not connect because the port is closed. I don’t want to use static ports. How do I undo?

Simon
2010/01/25

[...] REMOTE ITUNES SHARING [...]

In LA » Blog Archive » iTunes sharing over the internet using Back to my Mac and ssh port forwarding
2010/02/08

Participate