Using SSH Tunnel to Receive Incoming Connections

There's something I'm trying to accomplish using SSH tunneling, but I tried googling SSH tunneling in Google and found discussions on various scenarios, but not on my scenario.

I work on computer A. I have SSH access to computer B. I want computer B to run program X, which should connect to port 40,000 on computer A. The problem is that computer B has draconian firewalls applied to it that I do not want to change. I want to use my ability to easily connect to SSH from computer A to computer B to make connectivity from B to A.

This is what I assume: program Y, which I run on computer A, which connects to computer B via SSH, and then listens on computer B for connections to port 40,000 and forwards them through SSH connections to port 40,000 on computer A. Then I configure program X on computer B to try to connect to port 40,000 on computer B, and then it actually connects to port 40,000 on computer A.

Is there an existing program / SSH recipe?

+4
source share
1 answer

I think you are looking for the -R option for ssh:

 -R [bind_address:]port:host:hostport
         Specifies that the given port on the remote (server) host is to be
         forwarded to the given host and port on the local side.  This works
         by allocating a socket to listen to port on the remote side, and
         whenever a connection is made to this port, the connection is for-
         warded over the secure channel, and a connection is made to host
         port hostport from the local machine.
         [...]
0
source

All Articles