How to get started with remote pairing quicklyOctober 22, 2013 -
Remote Pair Programming is a thing now that people do. Basically, it enables you to learn from and work with anyone anywhere, ever. You can do that thing we love to do (write code) with a diverse range of people.
So let’s say you’ve decided you like this idea of getting out of the bubble of programmers you know well and you can’t to go see how the rest of the world lives. I’ll show you how to setup your Mac to do just that:
- Install the tools you’ll need.
You’ll need a few things here, easiest way to install them all is with Homebrew.
brew install tmux
Tmux lets multiple people use the same terminal session. This is way faster than relying on any screen sharing application and works even on less-than-epic internet. It also lets you do a bunch of fancy things (4 minute video) to manage multiple windows and split-screens in your terminal session.
brew install vim
Technically your OS X install comes with this already, but the version we get is not the latest version of Vim. They have fixed bugs and made improvements in performance and such since the version that ships on OSX. Also, you might find that some plugin decide to use just won’t work on the older version. Might as well install it while we’re here.
You’ll also want to grab a copy of ngrok. This is a convenient way to give people access to your laptop without needing to do all kinds of router configurations (which you maybe can’t do if you’re forced to use your ISP’s router, bleh). It also gives you some monitoring abilities, lets you track usage and keep up with who is using the connection.
- Let your partner onto your system.
Now I personally wouldn’t even give my password to my wife (if I had one), so here we’ll use ssh keys. Tell your pairing partner to send you their public key. If they use github already, you can find their keys by adding the extension “.keys” onto their profile url. For example, you can turn my profile url https://github.com/sgoodwin into https://github.com/sgoodwin.keys and see all of the public keys I’ve added. If they don’t have one already, github provides excellent documentation to explain how.
Once you have their key, you’ll want to add it to your
~/ssh/authorized_keys file. If you don’t already have this file, feel free to create it. You’ll want to add an entry (just a new line) in the file that looks something like this:
command="tmux attach" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3iQgxhX0Ozb6oy9eORGIY3HowlDtUfKpWNJCwiU2F1aRA9alsxeSvjJpOxqKip3Z7//ynPUK151r/ZU9aBmv43n3RITSUQqM1BAYoXPTCrQeehBJIzEE4wXFm8NUkSwTiF7xHdCDo7rnluz58qUWDpHxcb/XwZFt17zGO/PPuJcFkuy79la37xvol2fb9No2TON54ZBbx8Xi2IzEbxbWTmMc6K+vwwxZPIAQz5EL3vBRrtyT8RHjhF3G5Z1KmD6YkX9BaYnUbX+3WYVhzo19QRgiRgE9I5IP6KNSKJuxKBb4SaYdPJbn/cUPgvZmMj1oaoTUW2236FXglIjAaDoEx firstname.lastname@example.org
The first bit there supplies a terminal command which should be executed as soon as they login. I chose the command “tmux attach” which puts them directly into my tmux session so we can get started. Whatever command you put here, the ssh connection will close as soon as the command finishes. If you put
ls for example, it would print the contents of your home directory and then close the ssh connection. Now when they ssh into your machine, they’ll be tossed right into your terminal session and you two can get to coding.
Once ssh is configured, turn on ngrok and let them in with the command:
./ngrok -authtoken <YOUR AUTH TOKEN GOES HERE> -proto=tcp 22
This will open the gates to your machine and display the url your partner can use to find your machine with ssh. Once they do get ssh to connect, you’ll be looking at the exact same terminal session and you can get the party started.
- Connect with some audio
Now that you can both type, it’s helpful if you can both speak. Skype does an ok job with this (audio only, video and screen sharing are slow and mostly bad). You could also use something like FaceTime Audio which has excellent audio quality in my experience. Whatever you two want to use is cool. Use your cell phones even.
- I don’t know these Ngrok people very well, for all I know they’re recording all of my traffic to report to the NSA. Probably shouldn’t use it for your terrorist plots or for coding sessions where security of the code you’re looking at is super important. You’re working over ssh, so your work is encrypted, but you know, sometimes you need to be paranoid.
- If you start to feel uncomfortable about the person you’re going to pair with or even during the pairing session, pull the plug (just quit ngrok) and delete their key.
Even with these caveats, there are some advantages to setting things up this way:
- No need to manage your configs on a different system. I’m not a fan of maintaining configurations on more than one machine, so this is a big win for me.
- Dtrace. Another option you have is to share some server and work there instead of your own machine, but linux machines don’t get dtrace, your Mac does though!
- It will take you maybe 30 minutes to set this up. Your dev environment is already setup on your computer, all you have to add is the bits to share it with someone.
Now that you’re equipped to pair with people, you can go here to find more info about pairing and places you can go to find potential pairing partners. This is one of the ways we can get around not having enough more-senior developers near us. Go learn things!