Skip to content

Instantly share code, notes, and snippets.

@mfb2
Last active October 25, 2019 01:14
Show Gist options
  • Save mfb2/57255ca399da84563a56a13ec98724b6 to your computer and use it in GitHub Desktop.
Save mfb2/57255ca399da84563a56a13ec98724b6 to your computer and use it in GitHub Desktop.
Pair-up script
#!/bin/bash
#############################
# ./pairup
# tmux pairing setup script
#############################
# Prerequisites:
# tmux
# ngrok
# Before running this command, you'll need to add the public keys of the users you'd like to have connect to your session.
# For convenience, github public keys are a great way to go. It can be accessed via https://api.github.com/users/$username/keys
#
# e.g.
# ~/.ssh/authorized_keys -->
# command="/usr/local/bin/tmux new-session -t pairing -s $@-session" ssh-rsa <key goes here> https://github.com/username
tmux_user=${TMUX_USER:-$USER}
ngrok_host=${NGROK_HOST:-0.tcp.ngrok.io}
tmux new-session -d -s pairing "ngrok tcp --log /tmp/ngrok.log 22"
tmux split-window
sleep 1
ngrok_port=$(grep 'tcp://' /tmp/ngrok.log | tail -1 | awk -F':' '{ print $NF }')
ssh_command="ssh -p $ngrok_port $tmux_user@$ngrok_host"
tmux send-keys "$ssh_command" C-m
tmux attach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment