Setup SSH tunneling while pairing
23 Sep 2015I do a lot of Remote Pair Programming.
One of the things that people ask me about the most is what happens if my peer
needs to see the server/database or any other locally available resource that
is not easily accessible through the tmux session.
That is actually a great question.
When you pair using screen share, that’s obvious, you see everything I see, but
when we pair using a terminal you basically have a tunnel vision to my
computer. You can’t see the server (web server) I am working on or see some
JSON result that is describing the bug the best.
When working with rails for example, you have your default server at
localhost:3000
and when working with angular and grunt server it’s at
localhost:9000
.
Without being able to see the web server, pairing will be very difficult.
Before I knew about SSH tunneling setup, I actually had a Skype session set up
with screen share just to see the browser, but now, I have a better solution.
Setting up SSH tunneling
Lets say you want to access my localhost:3000
by going to localhost:3000
on
your computer, just like you would if you worked locally.
ssh -L 3000:localhost:3000 user@your-peer-ip
This command will forward all traffic on port 3000
to the computer you are
sshing to on port 3000.
If you already have a server running and port 3000 is busy, you can use any
other port.
I use this trick every single day, hope you find it as useful as I do.
Happy pairing!