Pairing in a Tunnel

We are keen that people can work in the spaces that makes them feel most comfortable, and allows them to organise their life how they want. Working remotely gives people that opportunity.

Pair programming is also an important part of the way we approach software development. The benefits that pair programming gives us and our clients are numerous and have been documented in several places.

These two practices seem to be at odds with each other. If people are working from a range of places, how can they be sitting next to each other programming?

Remote pair programming is difficult to get right, but we think the combination of tools we've arrived at works really well. I've blogged before about using vim and gnu screen, since then I've discovered tmux to replace gnu screen, but the concepts are the same.

The other important tool in our setup is ssh. This is how we gain remote access to each other's machines and allows us to make use of the tools. Using ssh is pretty straight-forward when there is one developer in the office and their pair is working remotely, its relatively simple for the remote worker to gain access to the office network - perhaps via an established vpn.

With a more widely distributed team things become more difficult. It becomes necessary to open ports on your home router, establish what your ip address is, an communicate that to the team. The more people you deal with the harder this becomes to manage!

Our solution is to use a central server (in our case a hosted vps) which everybody uses as a gateway. We simplify the management of this by creating an entry in our $HOME/.ssh/config file.

Host pairgate
  User user

Host pairhost
  User user
  RemoteForward localhost:2222 localhost:22

Host *.pair
  ProxyCommand ssh -e none -ax pairgate nc -w 5 localhost %p 2>/dev/null
  User pairing
  LocalForward localhost:3000 localhost:3000
  Port 2222

This allows us to easily start and stop remote pair sessions. The user who is hosting the session on their machine simply connects to the pairgate machine:

ssh pairhost -N

This sets up their connection to the gateway server, and opens port 2222 on the gateway. Any connection on this port on the gateway will be forwarded to port 22 - the ssh server - on the host machine. Essentially this allows the gateway machine to proxy ssh connections to the host machine.

The other half of the pair then simply needs to connect to the remote session.

ssh johndoe.pair

The ssh config for *.pair is a little more complex. The proxy command directive effectively allows us to ssh directly into the host machine. It also forwards our local port 3000 to the host's port 3000 - for rails development.

Using the *.pair directive means that we are able to use different names for different machines without hitting issues with server signatures changing.

This has been working fairly well for us over the last few weeks, and works even if the gateway machine has a fairly tight firewall. Its best if the gateway has a good net connection, and a relatively low ping for both users.

What tips and tricks do you have for remote pairing?

comments powered by Disqus