pcrr4w
Last Updated: February 25, 2016
·
5.44K
· mislav
8f93a872e399bc1353cc8d4e791d5401

Easily invite a person to pair with you in tmux

The long

  1. Verify that sshd is running on your machine:

    nc -zv localhost 22
  2. Get your external IP (make sure your router forwards the SSH port to you):

    curl icanhazip.com
  3. Get your pair's public key. You can fetch them from GitHub with github-auth:

    gh-auth add mislav
  4. Tell them to attach to your tmux session, which you can get with:

    tmux display -p '#{session_name}'

The short

I created a single command called pair that encapsulates all of the above steps and copies the ssh command on clipboard that you can paste to your pair. To pair with me, you would use it like so:

pair mislav

And a command would be copied to your clipboard:

ssh -t <MY-USER>@<MY-IP> 'tmux attach -t <TMUX-SESSION>'

This single line allows your pair to connect directly to tmux in one step.


Keep in mind that this gives your pair access to your computer (they effectively become you on your machine) and they can connect to any other tmux session as well without you knowing. If this level of access is unacceptable, consider pairing in a dedicated environment such as on a shared server or virtual machine.

A tip about syntax highlighting: if one of the people is using Solarized, then both need to have their terminals configured for Solarized, otherwise colors will look wrong and some code might even be invisible.

Say Thanks
Respond

5 Responses
Add your response

7641

Tmux will change your life. As @mislav said if you don't fully trust (or know) who you're pairing with, you can spin up a box on Nitrous.IO and create a tmux session there. It's safe, easy to add collaborators to your box, and it's free.

https://www.nitrous.io

disclaimer: I'm a nitrous.io co-founder

over 1 year ago ·
7661
Chip avatar

@mislav - Great tip! I definitely need to check out your pair command and also gh-auth. Very cool work there. On a related note, I tried tmate this week with a co-worker and it was really easy to use for pairing as well.

over 1 year ago ·
7932
257504fd74d069e658f5061126a00231

I actually prefer tweemux, because you don't necessarily need to worry about having a router forward a port to you.

over 1 year ago ·
8249
18deb990b168e39dd36674ced7d44250

Tks for the post, it was pretty useful! One thing that I had to do besides what you've written was adding a config to my /etc/sshd_config to use the new authorized keys:

AuthorizedKeysFile /Users/hugobarauna/.ssh/authorized_keys

Did you had to do something like that also?

over 1 year ago ·
8251
8f93a872e399bc1353cc8d4e791d5401

sshd should use your $HOME/.ssh/authorized_keys by default. I'm not sure why you had to enable it explicitly.

over 1 year ago ·
Filed Under