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

    Join Date
    Feb 2004
    Melbourne Australia
    Rep Power

    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: 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:
    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
    Rep Power
    From desktop computer you would run this in one terminal:
    desktop$ ssh -L 2221:routerc:22 serverb
    Then in a second terminal on desktop computer you would run this:
    desktop$ ssh -p 2221 localhost
    Leave the first terminal open to maintain the tunnel. The second terminal will be connected to routerc through serverb.

    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