Ssh – How to create reverse dynamic ssh port forwarding

port-forwardingsshssh-tunneling

I'm trying to set up an ssh tunnel layout where:

  1. client A (not ssh-server enabled) initiates ssh connection to server S
  2. socks server is opened on server S:yyyy that tunnels all data via client A
  3. client B connects socks server on server S, and tcp data routes via client A to the Internet

A possible solution would be to add a proxy server on Client A (binded to localhost:xxxx), and then run on client A ssh -R yyyy:localhost:xxxx Server. That would achieve the goal. But that's not as clean as using just ssh.

Is it possible to achieve this with just the ssh client on A and ssh-server on S? it's like reverse-dynamic-port-forwarding on ssh – creating ssh -D from A to S, and then somehow setup on this tunnel a second tunnel of ssh -D from S to A. Somewhat confusing, and not sure if possible.

Best Answer

OpenSSH 7.6 introduced reverse dynamic proxy as a native option. It is implemented entirely in the client, so the server does not need to be updated.

ssh -R 1080 server
Related Question