A couple people at work are in California, while most of us are here in St. Louis. We did a bit of screen sharing with Google hangouts, but it was laggy and one-sided. Only the host could make changes, and there was a lot of friction involved in switching the host. After looking around for a better solution, I found Martin Brochhaus’ blog post, Pair Programming With Tmux.
My setup is the same as his, with the small addition of
ngrok lets us avoid the trouble of setting up port forwarding for ssh.
Setting it up
This will be at a pretty high level, but more details are available on Martin’s blog
- Create a new user on your computer, called
pairor something similar.
- Authorize your colleagues to ssh into that user’s account.
- Add their public keys to ~pair/.ssh/authorized_keys
- On OS X, turn on
Remote Loginin the System Preferences.
- edit your
sshd_configto prevent password login.
wemux. On OS X, this is just
brew install tmux wemuxas long as you have homebrew installed.
wemux pair; exit. When the
pairuser logs in, they will join a
wemuxsession right away, and log out (
exit) immediately after leaving it. This keeps folks from doing insidious things on your computer. For example, they might add
echo 'say penguin' >> ~/.bashrcto your
~/.bashrc. By keeping them in
wemux, you can see everything they’re doing on your computer.
This is where the
ngrok secret sauce comes in. Up to now, our configuration has been the same as Martin’s. However, we won’t set up port forwarding on our router (maybe you’re at work, or a coffeeshop or an airplane and don’t have access to the router). Instead, we’ll use a ‘Secure tunnel to localhost’ provided by
You’ll have to download ngrok and put it somewhere on your
PATH. Now, run
ngrok -proto=tcp 22, which says “Make a TCP tunnel to my local port 22”. Port 22 is where ssh usually runs. You should get a screen like below.
You may have to create an account and authenticate your computer in order to use
-proto=tcp. Don’t worry — it’s free.
I happened to get port
35731. This number will be different every time. Now, start a wemux session by opening a new terminal window and typing
wemux start. Because of what we put in
.bashrc file, the
pair user won’t be able to stay logged in without a
wemux session running. Give it a try, as soon as you end
wemux (by typing
Ctrl-D), any users attached over ssh will be immediately logged out.
Now that you have
ngrok running, have your colleague log on using
ssh -p 35731 [email protected]. The connection will be forwarded from ngrok.com straight to your local computer.