Skip to content

Instantly share code, notes, and snippets.

@laurentsenta
Created September 7, 2019 11:19
Show Gist options
  • Save laurentsenta/658039086c6ddb32b917ad59a4412499 to your computer and use it in GitHub Desktop.
Save laurentsenta/658039086c6ddb32b917ad59a4412499 to your computer and use it in GitHub Desktop.
my "favorite" shell function
tunnel () {
machine="$1"
port_local="$2"
port_remote="$2"
if [ ! -z "$3" ]
then
port_remote="$3"
fi
echo "ssh $machine -N -L \"${port_local}:localhost:${port_remote}\""
ssh $machine -N -L "${port_local}:localhost:${port_remote}"
}
# Now you may:
# tunnel MyServer 8001 4001
# tunnel MyServer 27017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment