Music

iTunes sharing over the internet using Back to my Mac and ssh port forwarding

Monday, February 8th, 2010

I was at work the other week, doing a repetitive task of the sort that provides an opportunity to listen to music. I’d recently purchased an album and had stored it in the iTunes library on my home computer, but had not yet loaded the new songs onto my iPhone. There had to be a way to make iTunes at home share its music to my work computer so that I could listen to the new music. A few internet searches turned up some interesting information as well as a solution.

The crippled feature to be healed and exploited

Apple’s iTunes software has the ability to share selected playlists or entire libraries of music to other computers on a local network running iTunes. This means that if you have a large collection of music on your desktop computer, you can browse and listen to music from its library from a different room, streamed to your laptop. Or if you work in an office, and your coworkers have iTunes running on their machines and set to share, their shared libraries will automatically appear in the left column of iTunes running on your machine and you can play from them. It all works very seamlessly, on a local network. Possibly due to agreements made between apple and the recording industry, the sharing feature only works between computers on a local network, not between computers on the internet at large.

How iTunes sharing works

When a user tells iTunes to enable sharing in that application’s preferences, iTunes advertises that service on port 3689 of the local network using “Bonjour“, the name for Apple’s implementation of the Zeroconf standard. Bonjour is used by iTunes, iPhoto, and other applications to advertise and to find servers on a local network, such as within a home or office.

If a copy of iTunes is running on any other computers that are on the local network, those instances of iTunes will notice the advertisement of an iTunes share on the network, and will display the name of that iTunes share in the left column of the window. The user can then click that shared Library and play songs from it on their computer. The playlists and songs stream over the network from the sharer to the sharee. Unfortunately in my case, iTunes running on my laptop at work couldn’t see the iTunes share served from my computer at home, because my home computer is miles away and not connected to the same local network as my laptop.

Bringing the remote network closer

The following link pointed the way to a solution:1

REMOTE ITUNES SHARING

I recognized a familiar Unix trick in their tip: Port forwarding over a secure shell connection. Of course! If one could make a secure shell connection (abbreviated in the command “ssh”) to a remote computer, one could then do what’s called “port forwarding”, and forward all communications on a port on the remote machine to a port on the local machine. This would transport both the advertisement of the iTunes share and the actual sharing itself from the remote network to the local network. I’d never actually executed port forwarding over ssh before, but I’d heard of it, and between their example and the man page for the ’ssh’ command, it all became clear. The tip first requires that one knows the IP address of the remote computer, and then shows the command to connect to the remote machine, grab any communications on port 3689 (the port used by iTunes sharing), transport it encrypted to the local machine, and repeat it on port 36890 of the local machine. The command looks like this (hover your mouse over any portion of the command to see an explanation of that portion):

$ ssh -fNL *:36890:127.0.0.1:3689 USER@REMOTE-HOST

After that command successfully concludes, the iTunes share on the remote computer will be accessible to computers on the local network, except they won’t be able to see that it’s there. The second command in their document uses OS X’s built-in “dns-sd” command to advertise that there is an iTunes share on port 36890 of the local computer. It is this advertisement that will make the iTunes share appear in the sidebars of any copy of iTunes running on the network:

$ dns-sd -R "Remote iTunes" _daap._tcp local 36890 &

I was confident that this would all work, but for one snag. Like most people, my home computer only has an address on its local network, it doesn’t have its own internet address. The computer is connected to a router. The router has an IP address on the internet and an IP address on the local network and uses what’s called “Network Address Translation” to distribute connections from the outside internet to all the computers on the local network. If I tried to connect to the IP address of my home connection, I’d be connecting to the router, not my home computer with its trove of music. Luckily a solution was within reach.

Locating the remote computer using Back to My Mac

I recently purchased a “MobileMe” subscription, which includes a service called “Back to my Mac“. I’ll let Apple’s marketing folk, who’ve obviously seen Buckaroo Banzai, explain “Back to My Mac” for me:

Wherever you go, there’s your Mac.

Back to My Mac puts any Mac OS X Leopard- or Snow Leopard-based Mac you use within easy reach. MobileMe finds your remote Mac computers over the Internet and displays them in the Finder on the Mac you’re using. So you can connect from anywhere with just a click. Edit and save documents, open applications, and move folders. With Back to My Mac Screen Sharing, you can control your remote Mac as though you’re sitting in front of it.

I have been using the Back to My Mac service to copy files to and from my remote computer from work, and to occasionally take control of my home computer’s screen from work. The service must be punching through the router using port-forwarding and registering a temporary domain name for my home computer which can be accessed from the outside internet. I figured that if I could find out this domain name, it would be worth a try to use it to connect from work to the home computer and set up ssh port forwarding of the iTunes share. A search turned up this article:

10.5: How to use ssh using ‘Back to My Mac’

The writer of that article explains exactly how to determine the Back to My Mac domain name at which one can find their remote computer. When I tried the first method described, it did not work. As it turns out, that method works for short computer names, but my home computer’s name is long, and Back to My Mac truncates it and adds a few random (?) numbers when assigning the domain name. The second method they mention does work. I can easily determine the name assigned to my remote machine by choosing “Shell > New Remote Connection…” in the Terminal application’s menubar. In the “New Remote Connection” window that appears, I choose ’ssh’ in the service column and my remote computer’s name in the ‘Server’ column. There, in the field at the bottom of the New Remote Connection window will appear the command for making a ssh connection to my home computer. It’s not the same ssh connection command that will be used to do port forwarding, but the last portion of it does show me the exact domain name that will resolve to my home computer.

Victory

Whenever I feel the mood, I can now run the following two commands and then sit at work listening to streaming music stored on my home computer:

$ ssh -fNL :36890:127.0.0.1:3689 myComputerName.myMobileMeID.members.mac.com.

$ dns-sd -R "Zach's Remote iTunes FTW" _daap._tcp local 36890 &



Thanks Y’all

Thank yous are due to the writers of:
  1. All the solutions written below involve the use of the Terminal application and the command-line. If you’ve never played with such, give it a shot. Stop kvetching and open /Applications/Utilities/Terminal. You paid for a Unix operating system when you bought your Mac, you might as well try exploring some of its inner awesomeness. []

An unexpected musical treat: Letters vs. Numbers

Tuesday, August 4th, 2009
Img 0955
The other day I unexpectedly received a CD in the mail, from a sender whose name I didn’t recognize. The band: “Letters vs. Numbers”, album: “Bone Tired”. The back of the sleeve was a handwritten list of other recipients along with a printed request that the recipient rip the album to their computer, add their name and location to the list, and send it to someone else.

Always one to obediently follow directions, I ripped, signed, and sent. I also listened, and damned if it isn’t a great little album. Here’s the first track, “Forget Everything”, for your streaming or downloading pleasure1 :

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

download mp3

I’d highly recommend that you receive this album by mail from a friend or an anonymous source. Failing that, the mysterious band2 has a website, a myspace page3, and the album is available at both the iTunes music store and the Amazon MP3 store.

  1. Hit the triangle button to play the track in your browser, or the download link to download the mp3 file []
  2. Their myspace page doesn’t list the names of band members, their number, or even a location. []
  3. The album can be listened to on the page in that icky myspace music player widget. []

Nice Deal: Shure i2c in-ear monitors (earbuds)

Tuesday, November 4th, 2008


“Shure I2C-MP Stereo Earphones / Headset (iPhone Compatible)” $39.69 at Amazon.com

I previously owned a pair of Shure e2c earphones, which were very nice. When used with the foam earpieces, they isolate from ambient noise and produce a very detailed sound with a decent amount of bass. I ended up listening through them at a much lower volume than I would have with less isolating headphones.

Shure makes a set of earbuds called the i2c, which are simply their e2c earbuds with the addition of thicker cables, an inline microphone, and an iPod connector (looks like a standard 3.5″ stereo jack except it has one extra conductor for the mic). As an iPhone headset, the i2c has faced some criticism due to the fact that it lacks an inline answer/hangup button. Perhaps because of this minor inconvenience, Amazon.com has recently dropped the price of the i2c headsets from $119 to about $39.

I don’t care about the button, or the mic, since I don’t have an iPhone. For a nice pair of earbuds, that price happens to be a great deal. I placed my order last week thinking that if the iphone plug wasn’t compatible with my ipods that I’d cut it off and solder a standard miniplug in its place (ignoring the mic wire). It turns out that the iPhone connector works fine in both my 1st-gen iPod Nano and 1st-gen iPod Touch. Right and left channels nicely separate, and the sound is good. The mic connector on the plug doesn’t seem to short or otherwise interfere with the contacts for the audio outputs –your mileage may vary. It’s working for me (I suspect the connector was designed to work in both iPhone and standard mini-stereo jacks, but don’t quote me on that).

If you buy a pair of i2c’s (or any in-ear monitors really) I’d recommend tossing the silicone sleeves they ship with (with extreme prejudice) and instead using compressible foam tips so that the earbuds really make a nice seal in your ear. The sound quality will be much improved, and the bass presence and detail will increase. Shure sells orange foams that works well, many on the net tout Shure’s tapered black “olive” foam sleeves for greater comfort and cleanability, and I’ve heard good things about the Comply viscoelastic polyurethane memory foam tips.

I ‘m happy to now have a nice pair of earbuds to use for running (My Future Sonics FS1’s finally died, and I don’t want to subject my FS Atrios to the same abuse). Yay. If you’ve been thinking of replacing your iPod earbuds with something better, this here’s a very good deal (on something much much better).

Tokyo Police Club at The Music Box, 2008-09-18

Friday, September 19th, 2008
P1000237

Tokyo Police Club played The Music Box last night, and I and a friend who likes to go nameless attended. I thought the show was great, and found the band’s amped-up shoegazer style refreshing, he had the opposite reaction, and left early. I think it helps to hear their music and know some lyrics beforehand –it’s deceptively non-accessible stuff despite the driving beat. The acoustics in the club were such that it was difficult to pick out the different layers of sound.

I shot a few photos with my digital point-and-shoot, they can be accessed by clicking the photos in this post.

Tokyo Police Club At The Music Box, 2008-09-18 - A Set On Flickr


Bad Behavior has blocked 300 access attempts in the last 7 days.