Skip to content

Instantly share code, notes, and snippets.

@mveytsman
Last active April 11, 2019 13:38
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 mveytsman/55e06c725443fe63cb1e4519ab21520a to your computer and use it in GitHub Desktop.
Save mveytsman/55e06c725443fe63cb1e4519ab21520a to your computer and use it in GitHub Desktop.
Localtunnel replacement
#hacky way to get a hosts ip
function ipfor() {
ping -c 1 $1 | grep -Eo -m 1 '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';
}
# localtunnel replacement (note that I default ssh to port 443 because thats how I roll
localtunnel() { if [ $# -lt 2 ]; then echo "Usage: localtunnel hostname port [ssh_port]"; else ssh_port=${3-443}; echo "Setting up localtunnel on `ipfor $1`"; ssh -N -R "*:0:localhost:$2" $1 -p $ssh_port; fi;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment