Skip to content

Instantly share code, notes, and snippets.

@ajkavanagh
Forked from gotbadger/gist:4979243
Last active December 27, 2015 00:19
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 ajkavanagh/7237185 to your computer and use it in GitHub Desktop.
Save ajkavanagh/7237185 to your computer and use it in GitHub Desktop.
#!/bin/bash
# setup local
BIND_ADAPTER="en0"
LOCAL_PORT=4000
# setup remote
REMOTE_USER="user"
REMOTE_HOST="server.example.com"
REMOTE_PORT=9999
echo "Make sure $REMOTE_PORT is open on $REMOTE_HOST and 'GatewayPorts yes' is set in the remote sshd.conf"
LOCAL=$(ifconfig $BIND_ADAPTER | grep 'inet ' | cut -d " " -f2 | awk '{print $1}')
echo "$REMOTE_HOST:$REMOTE_PORT -> $LOCAL:$LOCAL_PORT"
ssh $REMOTE_USER@$REMOTE_HOST -N -R $REMOTE_PORT:$LOCAL:$LOCAL_PORT
@ajkavanagh
Copy link
Author

That looks cool! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment