My favourite gadget that I bought
last year was my
Squeezebox Duet. But one of the best things about the whole Squeezebox package is actually the software. The server is open source, which means I could play with it for a while before I splashed some cash on the hardware. It's what won me over.
What's also won me over is this: with the server running at home, and a little set up, I can play music from my collection from wherever I am (with my PC and a network connection). None of this is difficult (if you know how to tunnel TCP ports over SSH, you can probably go somewhere else now) but I wanted to document it so I can repeat it if/when necessary.
These instructions were originally for an Ubuntu 9.04 server, already running Squeezebox Server. I've now also used them with on a
Pogoplug running Debian Squeeze. The client could be any Linux as it's all command line; I've used with Ubuntu 9.10, 10.04 and 11.04. YMMV. Etc.
Firstly, I set up a key on the client that to be used to authenticate with the server. The Ubuntu documentation has a
good guide, including an explanation of why a pass phrase is a good idea. The steps I used were:
- Open a terminal
- Enter
ssh-keygen -f ~/.ssh/id_rsa -t rsa -b 4096
- Enter your pass phrase twice.
Then I used a USB key to copy the public key (
id_rsa.pub
) to the server.
Next, I prepared the server:
- Installed the SSH server by installing the
openssh-server
package.
- Configured SSH to only allow key-based authentication and change the port SSH listens on. Both of these will make SSH more secure (remember that I am allowing external access to the server, so these measures are worthwhile). Edit the SSH server's config file (
/etc/ssh/sshd_config
) and add or modify the following lines and restart SSH (more details):
PasswordAuthentication no
Port 1234
- Allowed the client to login to the server by taking the
id_rsa.pub
file from the client and appending its contents to the file /home/user/.ssh/authorized_keys
, (where user
is the user name on the server).
- My server is behind a firewall, (a cable modem/router thing), so I needed to forward the relevant port (1234, as configured above) from the router to the server.
- I use dyndns.org to set up a constant DNS name for my router, which can use this service automatically. Then I don't have to worry about remembering what IP address my ISP has given me or whether it has changed.
Then I prepared the client.
- I checked that SSH was working on the local network before anything else. In a terminal, enter
ssh -p 1234 user@192.168.0.10
Where 1234 is the configured SSH port and 192.168.0.10 is the server's IP address. The first time I did this I got a message telling me that the server's identity could not be verified. I accepted this and entered the key's pass phrase.
- The SSH client now needed to be configured to forward a couple of ports to the remote server. This can all be set up on the command line, but it's easier to put it in a config file. I edited the file
~/.ssh/config
and added the following lines:
Host home
HostName myserver.dyndns.org
Port 1234
User user
Compression yes
LocalForward 3483 192.168.0.10:3483
LocalForward 9000 192.168.0.10:9000
LocalForward 9090 192.168.0.10:9090
(where 192.168.0.10
is the IP address of the SqueezeboxServer on the local network). Now using SSH from a remote location is as simple as typing ssh home
and all the relevant addresses and ports will be used.
- The client software I use is SqueezeSlave. It's a headless (no UI) open-source software version of the Squeezebox. Other players are available:
- SoftSqueeze is a Java clone of the Squeezebox itself, with a UI, display and all. I found it unreliable on Ubuntu and over-sensitive to what else is running.
- SqueezePlay is ostensibly the replacement for SoftSqueeze but despite many attempts to compile it, it seems not to like PulseAudio on Ubuntu so although it functions as a controller, it won't produce any audio.
- Any software player that can work with MP3 streams, using these instructions. The difference between using this method and using SqueezeSlave is that the server has to transcode everything to an MP3 stream first, whereas SqueezeSlave receives the raw bytes and plays them directly, locally.
Once downloaded, I put the appropriate version of the squeezeslave executable in /usr/bin
- Now to run SqueezeSlave remotely, I first run SSH like this:
ssh -f home sleep 10
This runs ssh in the background and runs the sleep command. This is a bit of a trick. ssh will exit once it's run the command, *unless* the tunnel is being used. So if you issue the next command within those 10 seconds, ssh won't exit until squeezeslave exits.
- Then I run SqueezeSlave like this:
squeezeslave -m 00:00:00:00:00:03 localhost
where the -m
option specifies a fake MAC address, which is used by the SqueezeboxServer to distinguish between players, thereby remembering settings for each player. The "server" is localhost
because SSH is tunneling the requests for ports 9000 and 3843 to the real server.
- I then control the player using the web UI from a browser at
http://localhost:9000