Skip to content

Instantly share code, notes, and snippets.

Last active Apr 12, 2020
What would you like to do?
Remote Pairing (through SSH tunnel) Setup

Start with a machine that is directly accessible to both parties via SSH (linode, EC2,, etc), and that you can add users to. DO NOT USE root!!!!


##From the hosts local machine:

ssh -R1337:localhost:22 host@<shared server's ip address/hostname>

In another terminal window (or tab):

tmux -S /tmp/pair

Then from inside your new tmux session execute:

chmod 777 /tmp/pair

From the pairs local machine:

ssh pair@<shared server's ip address/hostname>


##Shared Host Setup - Once

Setup a user for the host of the pair session:

sudo adduser host

sudo su - host
mkdir ~/.ssh
chmod 700 ~/.ssh

Setup a user for your pair to connect as:

sudo adduser pair

sudo su - pair
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa -C "pair@ircely" 

Shared Host Setup - Each Pair

Add the following to the users authorized_keys file:

command="ssh pair@localhost -p 1337",no-port-forwarding,no-X11-forwarding,no-agent-forwarding <pair users public key (can use github API like:> 

Shared Host Setup - Each Host

Add the host users public key to the /home/host/.ssh/authorized_keys file

Local Setup - Each Host

Add a user for the pair to your local system:

On ubuntu/debian:

sudo adduser pair

(Use system preferences for Mac OSX)

# execute the following once the user is created
sudo su - pair
mkdir ~/.ssh
chmod 700 ~/.ssh

Add the following line to the pair users ~/.ssh/authorized_keys (note that the /usr/local/bin/tmux bit will be different based on the location of tmux executable):

command="/usr/local/bin/tmux -S /tmp/pair attach",no-port-forwarding,no-X11-forwarding,no-agent-forwarding <pair-users-ssh-public-key (from shared internet host /home/pair/.ssh/> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment