Easy port forwarding


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. #!/bin/sh
  2.  
  3. LOCALPORT=$1
  4. REMOTEHOST=$2
  5. REMOTEPORT=$3
  6.  
  7. socat -d -d -lmlocal2 \
  8. TCP4-LISTEN:${LOCALPORT},fork,range=127.0.0.1/0,reuseaddr \
  9. TCP4:${REMOTEHOST}:${REMOTEPORT}

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.