Easily invite a person to pair with you in tmux
The long
-
Verify that sshd is running on your machine:
nc -zv localhost 22
-
Get your external IP (make sure your router forwards the SSH port to you):
curl icanhazip.com
-
Get your pair's public key. You can fetch them from GitHub with github-auth:
gh-auth add mislav
-
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.
Written by Mislav Marohnić
Related protips
5 Responses
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.
disclaimer: I'm a nitrous.io co-founder
I actually prefer tweemux, because you don't necessarily need to worry about having a router forward a port to you.
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?
sshd should use your $HOME/.ssh/authorized_keys
by default. I'm not sure why you had to enable it explicitly.