Skip to content

Instantly share code, notes, and snippets.

@keithpitty
Last active December 15, 2023 16:24
Show Gist options
  • Save keithpitty/38266d38d44d06fabf6b707df608f73e to your computer and use it in GitHub Desktop.
Save keithpitty/38266d38d44d06fabf6b707df608f73e to your computer and use it in GitHub Desktop.
Pairing with tmux and ngrok

Steps for Remote Pairing using tmux and ngrok

The following steps facilitate remote pairing using:

  • tmux which allows terminal sessions to be attached to different terminals, and
  • ngrok which provides secure tunnels to your localhost

1. Install tmux

OS X: brew install tmux

Linux: sudo apt-get install tmux

2. Download and install ngrok

3. Spin up TCP tunnel

Note: You can skip this step if you are just connecting to a colleague's tmux session.

To establish a secure SSH tunnel and allow port forwarding via ngrok:

ngrok tcp 22

4. Authorise remote user(s)

Note: You can skip this step if you are just connecting to a colleague's tmux session.

If you haven't already:

gem install github-auth

Assuming you want to authorise GitHub user tcuser2 to a tmux session called tc which has already been established:

gh-auth add --users="tcuser2" --command="$(which tmux) attach -t tc"

This will ensure that user tcuser2 can use tmux to attach to session tc.

5. Connect via ngrok

Assuming your GitHub userid is tcuser1 and your ngrok TCP session is using port 12345, you will need to tell your colleague tcuser2 to connect using:

ssh -p 12345 [email protected]

Provided prerequisite steps 1 and 2 have been followed, the secure SSH tunnel has been established via ngrok and tcuser1 has used gh-auth to authorise tcuser2 to attach to tmux session tc, user tcuser2 will be then attached to the tmux session running on tcuser1's machine.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment