Skip to content

Instantly share code, notes, and snippets.

@muety
Created December 3, 2020 13:33
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 muety/3b68db27db7d3f9a1c71afcfd2d4adca to your computer and use it in GitHub Desktop.
Save muety/3b68db27db7d3f9a1c71afcfd2d4adca to your computer and use it in GitHub Desktop.
Reverse tunneling to localhost using SSH (ngrok alternative)
#!/bin/bash
# Requires 'GatewayPorts clientspecified' to be set in /etc/ssh/sshd_config
HOST="muetsch.io"
REMOTE_PORT="8080"
REMOTE_BIND_V4="127.0.0.1"
PROXY_URL="https://local.muetsch.io"
echo -e "----------- localssh -----------"
echo -e "Usage: localssh.sh <LOCAL_PORT>"
echo -e "--------------------------------"
if [[ "$1" == '' ]]; then
echo -e "Missing parameter."
exit 1
fi
echo -e ""
echo -e "Go to $PROXY_URL once the session is established"
echo -e ""
ssh -R "$REMOTE_BIND_V4:$REMOTE_PORT:localhost:$1" "$HOST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment