I have an iPhone. The old kind. Not the really old kind, but the one that is now two generations behind current. You know, the one Steve Jobs is trying to make me hate by not allowing any new features and slowing it down with each and every update. The 3G they call it. Add to that the fact that, being the poor/cheap asshole that I am, it’s not even a 16gb one, and I’m walking around with 8gb of pure, once cutting-edge technology in my pants. And with all of these “SEXY SECRET MAGIC TRICK!” and “BIKINI BABES!” apps and the latest episodes of Desperate Housewives and Real Housewives of NYC (really I just do a search for anything with “Housewives” in it), I’m not left with a whole lot of space for my music. Being one of those professional computer nerds, I need my music for work. Programming in silence is like a peanut butter and jelly sandwich without the bread; yeah it still basically works, but you’re gonna get your hands pretty sticky.
This, and the undying need to piss off my fellow IT professionals, led me to find a way around this problem, and get my iTunes library streaming directly to my work computer.
iTunes Over SSH
or: Because Pandora Just Plays the Same 20 Goddamned Songs Over and Over
This might get a bit technical, but if you don’t get what I’m explaining, just blindly follow the instructions and type what I tell you into th boxes and you’ll be fine. This may look like some terminal-induced demonry, but the overall idea is pretty simple, I promise.
SSH, Ports, Tunneling, Blah Blah Blah
Okay, so first I’ll explain the basics. If you already know this, skip ahead.
There’s this magical thing called SSH. It stands for Secure Shell, and comes built in on everything Unix or Linux based like Mac OS X or Ubuntu. It’s kind of like remote desktop, but without all that annoying user interface stuff. It lets you log in and turn your current command line into the command line on the remote machine. So if I’m sitting here at work and I SSH into my laptop at home, I can move my massive porn collection somewhere safer before my mom accidentally stumbles onto it while searching for new curtains even though I told her to stay out of my damn room. It doesn’t take over the screen like VNC or Remote Desktop does, and it’s about a thousand times faster because there’s no screen to transmit back and forth. But that’s not all it does. SSH also has a feature called Tunneling, which lets you use ports in interesting ways. You may or may not be aware of things called ports on your computer. Not like the hole you stick your mouse (or other things) into. These don’t physically exist anywhere except your imagination. And inside the operating system I guess. But mostly imagination. Think of them like individual network plugs, except your computer has thousands of them, and they can only do one specific thing at a time. For example, when you IM your secret boyfriend on AIM, it uses port 5190 (unless you’re a clever bastard and changed it yourself.), and nothing else on your computer can use that port while AIM has itself stuck in that window, eagerly awaiting his reply. Thousands of ports, each for one specific network or internet connection. Okay, now let’s dick around with that. One of the basic functions of firewalls is to block traffic moving through certain ports. So when you’re at work, the company doesn’t want you breaking all their shit or letting anyone else in who possibly could, so they probably block most ports except the really common ones. SSH typically uses port 22, which is generally left open. Tunneling, basically, lets you connect to a remote server via SSH with port 22, then take some connection on that remote host on whatever port you give it and forward it through the SSH connection on port 22, to a certain port on your computer. In the same way that your local terminal becomes the terminal for the remote computer, the local port you specify becomes the remote port. Say you have some private email server that you love and you want to send something through it, but you’re somewhere else and the server only allows you to send if you’re in the same local network. So you SSH into the thing, and tunnel port 21 on the remote host to port 17434 on your computer. Now you tell your email app that your outgoing mail server is 127.0.0.1:17434. 127.0.0.1 is the IP address for this computer that you’re on right now, and then you put a colon and the port number to specify that. Because of the tunnel, 127.0.0.1:17434 is now essentially the same as :21 on the email server, and yuor messages go the way you want. You’ve done your job well. What’s that you ask? Why can’t we also tunnel whatever port iTunes uses for Library sharing, and BAM Library? Well, look at you, laying down internets tubes and tossing around datas. That’s exactly how this works.

Now just picture your little mp3s running down there.
Okay, so now you get the concept (or you got bored and skipped to this part to download some crap and type in some numbers to listen to your goddamned music already). Just two more details.
- Port 22 needs to be open to connect to on the sharing computer, and you need to have an SSH server running to actually connect to. Unfortunately, if the music you’re trying to share is on something like a College connection or inside your company’s firewall, you won’t be able to do this, and I have completely wasted your time. Problem? You need to have access to the router to make it so you can connect to your computer from the outside. If you do have access to your own router, This Site will explain how to set up the port forward that you need, with the specific instructions for your router. Get on it, forward port 22, NOW. And write down or remember your external IP address, since you’ll need the address of the thing you want to connect to. Next, to set up the server, if you’re a Mac user, just go to System Preferences > Sharing and turn on Remote Login. If you’re on Linux, you already know how to do this, so stop asking. Windows, just Google “OpenSSH server windows” and you’re golden. Easy as that.
- Apple doesn’t want you to share your music over the internet, so it only listens to a specific service called DAAP, which runs on local networks through something called Bonjour. That’s all I needed to know, so I didn’t bother to find out more. This we can fix incredibly easily with one download. I’ll get to that later.
How to Actually Do This
Alright, you ready? Let’s go. You’ve got your SSH server running, you turned on iTunes sharing (I didn’t mention this, but…come on.), and now is a good time to make sure you have passwords on both of these. Your account will be your SSH login, and since you just opened it to the world, you’ll need to have one, and password protecting the iTunes share is probably a decent idea too, since you don’t want people killing your bandwidth.
First, we need the tunnel. On Mac or Linux, open a Terminal. On Windows, go get Cygwin, a *nix terminal emulator (make sure you check the netutils and OpenSSH packages under the ‘net’ section when it asks what parts to install). And then open it, too. Type this, but replace YOUR_SERVER with your external IP address, and YOUR_USERNAME with your (guess, come on guess) username.
1
| ssh YOUR_USERNAME@YOUR_SERVER -NL 36890:127.0.0.1:3689 |
And press Enter. It should ask for your password, so help it out. The letters don’t show up as little stars, or at all, but I promise it’s getting what you type. Then nothing should happen. If you get an error like “connection refused” you probably didn’t forward the port correctly. And if it says your password was wrong, you should try typing it again, but right this time. If you just have a little blinking cursor, then you also have an open tunnel. Sweet.
OPTIONAL: You can check that this is actually forwarding your iTunes share through the tunnel with something called telnet. Open up another Terminal or Cygwin window, and type in:
Wait til you see a bunch of crap and the last line “Escape character is ‘^]’”, and press Enter twice. This should close the connection with a Bad Request error from a DAAP-Server. Don’t worry about what that means at all, as long as it spits out something that says DAAP-Server: iTunes, it means it’s working. Anything else means the tunnel isn’t forwarding your port at all, and you need to go try that again.
Now look at you. SSH tunneling your DAAP server to localhost port 36890. You’re practically a computer science major.
Now you just have one last thing to fix. The DAAP is on your computer but iTunes won’t play with it because it’s not in Bonjour. This we can fix with something called dns-sd, but in different ways on different OSes.
- Windows: Download Bonjour Beacon. It’s the only thing I could find that wraps all the dns-sd crap into a user interface, but it’s pretty buggy and hasn’t been updated since 2009. But it mostly works for now. Fill it in like this

but Host MAC: should be your actual MAC address rather than some clever observational humor. If you don’t know how to find that, click here. Type it in without the dashes, click Add New, and then the ‘Start’ button when it shows up in the list on the bottom. The annoying part of is that it doesn’t properly save these profiles. So when you close it, next time it opens, it won’t work. You’ll have to delete the profile and type it in again. Stupid but the best we’ve got at the moment.
- Mac OS X: Download Network Beacon. Does the dns-sd work for you and seems to do a pretty damn good job of it. Add a New beacon, like this.
That bottom part about the proxy is easy, just click Look up host, and it should fill in the appropriate information. Or you can plug in 127.0.0.1 for the address and that works too.
- Linux: Hahahaha, you’re on your own for this part, pal. No idea, but I’m sure Google can help you. Look for stuff about setting up Bonjour beacons with dns-sd and you’ll be on the right path.
Next step, open iTunes on your computer, look for a new shared library (it’ll probably be some weird name at first), open that fucker up, and ROCK OUT WITH YOUR COCK OUT.
You’re welcome.
Comments Off