#1
  1. C Neophyte.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Melbourne Australia
    Posts
    405
    Rep Power
    46

    TCP port forwarding using SSH


    I did a quick forum search but couldn't find an answer to this one

    How do I enable port forwarding using SSH?

    I have three devices

    1- Desktop Computer
    2- Server B (named bems)
    3- Router C

    I want to be able to ssh from computer to Router C , through Server B; hence I need to set up port forwarding on Server B

    (see attached image file)


    I have tried this but this does not work:
    unix Code:
    server-b# ssh -L 2221:203.44.175.197:22 localhost



    ... I keep getting "Fatal error, connection refused"


    Aside - Socat

    I have socat partially working and ssh is forwarded,

    but each time I run my script that automates SSH, it crashes...
    unix Code:
    server-b# /opt/csw/bin/socat -ddd -v -ls -s -4 tcp-listen:2221 tcp-connect:203.44.175.197:22
    Attached Images
    For one to know everything, first one must accept he knows nothing.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    From desktop computer you would run this in one terminal:
    Code:
    desktop$ ssh -L 2221:routerc:22 serverb
    Then in a second terminal on desktop computer you would run this:
    Code:
    desktop$ ssh -p 2221 localhost
    Leave the first terminal open to maintain the tunnel. The second terminal will be connected to routerc through serverb.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo