Skip to content

Instantly share code, notes, and snippets.

@javiermon
Last active December 17, 2015 19:09
Show Gist options
  • Save javiermon/5658306 to your computer and use it in GitHub Desktop.
Save javiermon/5658306 to your computer and use it in GitHub Desktop.
tunnel ssh for remote connections (for all connections: 0.0.0.0)
#!/bin/bash
if [ "$#" -ne 1 ]
then
echo "SERVER:RPORT:LPORT argument required"
exit 1
fi
# parse parameters separated with ':' into bash array
PARAMS=(${1//:/ })
SERVER="${PARAMS[0]}"
RPORT="${PARAMS[1]}"
LPORT="${PARAMS[2]}"
if [ "$LPORT" == "" ]
then
LPORT=$RPORT
fi
ssh -f $SERVER -L 0.0.0.0:$LPORT:$SERVER:$RPORT -N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment