For the past few months I've been using tmux to manage my terminal sessions.
tmux is a terminal multiplexer, which allows you to manage multiple terminals within a single session.
One of the great features of tmux is session sharing. This means you can use it for pair programming if you both use a terminal-based text editor.
To use tmux for pair programming we need to do a fair bit of manual legwork.
- Create a tmux session
- Make the session writable by other users (every time we create a session)
- Set up a user
- Enable "Remote login"
- Connect the user to the tmux session on login
- You are ready for an inbound connection at last!
- At the end of our working session, we want to disable the remote login
To smooth out the process I wrote a collection of scripts and packaged them up in a gem. With the gem installed the workflow becomes:
# Installation
$ gem install pairup
$ pairup setup # Create the `Pairup` user
# Run (host)
$ pairup auth <github username> # Get the public ssh key for your colleague
$ pairup start
# Connect (client)
$ ssh pairup@<ip address of host>
# End session
$ pairup stop
If the host is behind a LAN, you can use a service like ngrok.
# After running `pairup start` (host)
$ ngrok -proto=tcp 22
# Connect (client)
$ ssh [email protected] -p <ngrok port>
Remember, the guest user has the same access as the host, make sure you trust your partner.
Happy sharing!