December 4th, 2012, 10:59 PM
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:
server-b# ssh -L 2221:126.96.36.199: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...
server-b# /opt/csw/bin/socat -ddd -v -ls -s -4 tcp-listen:2221 tcp-connect:188.8.131.52:22
For one to know everything, first one must accept he knows nothing.
December 4th, 2012, 11:53 PM
From desktop computer you would run this in one terminal:
Then in a second terminal on desktop computer you would run this:
desktop$ ssh -L 2221:routerc:22 serverb
Leave the first terminal open to maintain the tunnel. The second terminal will be connected to routerc through serverb.
desktop$ ssh -p 2221 localhost