Return to Snippet

Revision: 2441
at February 19, 2007 14:10 by drewr


Initial Code
#!/bin/sh

LOCALPORT=$1
REMOTEHOST=$2
REMOTEPORT=$3

socat -d -d -lmlocal2 \
    TCP4-LISTEN:${LOCALPORT},fork,range=127.0.0.1/0,reuseaddr \
    TCP4:${REMOTEHOST}:${REMOTEPORT}

Initial URL


Initial Description
Need to forward a port through SSH, but you don't have shell access to the box?  If you have access to another box that can get to the desired port, use this script.  You need socat (http://www.dest-unreach.org/socat/).

  ./script-name 10000 other-host 10001

Initial Title
Easy port forwarding

Initial Tags


Initial Language
Bash