Created
February 18, 2013 17:54
-
-
Save gotbadger/4979243 to your computer and use it in GitHub Desktop.
Setup SSH tunnel on OSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment