Skip to content

Instantly share code, notes, and snippets.

@ndrluis
Forked from keithpitty/tmux-ngrok.md
Created May 19, 2021 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndrluis/e91e85dc6c90663427e3011bffb2e119 to your computer and use it in GitHub Desktop.
Save ndrluis/e91e85dc6c90663427e3011bffb2e119 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 tcuser1@0.tcp.ngrok.io

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