Mac OS X users and faithful readers of TUAW know that there is great power found in the command-line, but one of the greatest advantages of OS X’s UNIX heritage is the secure shell (SSH) client and server. From the Apple Matters article on SSH tunnels for the common man: “SSH is a network protocol that provides secure communication between two computers.” Its power comes from the ability to create an encrypted tunnel through which a client can send many types of internet traffic.
The Lifehacker article on setting up an SSH server covers the steps necessary to roll your own SSH server whether you are running Windows or OS X. Parts one and two of the Apple Matters series on SSH tunnels provide a lot of useful information on SSH as well as creating an SSH tunnel for encrypting traffic. One such use that has not yet been covered is how it is possible to stream your iTunes library across the internet while using software that is either built-in or available for free.
This tutorial will get pretty technical and assumes that you already have an SSH server and you know how to access it from a remote location (e.g. from work). If you are already past the point of just setting up an SSH server and are asking yourself “what now?” then read on to find out how you too can listen to your tunes at work even though they are trapped at home.
For starters, we must set-up an SSH tunnel from our local machine to our remote SSH server. There are several applications that can be used to create the tunnel such asJellyfiSSH (free) or Meerkat (not free) for OS X and PuTTY for Windows. Additionally, the tunnel can be created from the command-line using Terminal; if you are on Windows you will need to get Cygwin. The tunnel should be created such that you wish to access a remote service on port 3689 of your SSH server and have that forwarded to some random local port above 1024. If you use a port lower than 1024 it will require root privileges and for this reason I recommend something simple like 36890. If you’re doing this the command-line way you’re going to run something akin to the following:
“ssh user@remote_server_ip -L 36890:127.0.0.1:3689”
In a nutshell the command above says to create an SSH tunnel that forwards the service running on port 3689 at the remote server to port 36890 on your local computer. To test the connection you can telnet to “127.0.0.1 36890” and then hit <enter> twice. This should list a killed connection to DAAP-Server: iTunes; if it does then your tunnel is up and everything is ready to go. If this does not work check to make sure that iTunes is running on the remote server, make sure library sharing is enabled or try verifying port 3689 is open at the remote server.
Now that the SSH tunnel is running smoothly, it’s time for the magic portion of the show. You’re going to need to grab an application called RendezvousProxy from here. RendezvousProxy is required for iTunes to be notified of the shared library’s availability. If you are using Windows grab the only binary available and download it. On OS X you will need to download the binary for Java as the OS X binary does not seem to work in Leopard. There is no need to run the included script called “runme.sh” (it will not harm anything, it is simply unnecessary). Launch RendezvousProxy by double-clicking the included jar file; when the application appears you will need to add a host and configure it as shown here:
Once the new host has been added you should see a link to the shared library in iTunes:
At this point you can click on the newly added iTunes library share and start jamming out to the new Britney Spears Killers album. Keep in mind that if you are on dial-up or a similar low-bandwidth connection, the music may skip and problems could occur for users on the network where the SSH server resides. However, if you’re rocking with a good connection and tons of tracks to choose from then you should have no problem finding some music to listen to — probably annoying all of your co-workers.
One more thing: if you happen to have Xcode installed and want to go a step further with this little project it is incredibly easy to fix the OS X binary. All you have to do isdownload the source, open the project in Xcode, and re-build. Also, if you don’t need an interactive terminal session open for the purpose of sending other commands to the SSH server you can add the “-N” flag to the command so it reads “-NL” instead.