Skip to content

Instantly share code, notes, and snippets.

@muety
Created Dec 3, 2020
Embed
What would you like to do?
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