ssh -D <port> <[email protected]>; but in reverse? [closed]
Asked Answered
I

1

25

Is it possible to set up an SSH tunnel with dynamic port forwarding like this:

ssh -D

but do it the other way around? That's to say I want to initiate the connection on my local machine and have the dynamic port forwarding happen there, and have my friend connect his browser to the other end of the tunnel.

The above works perfectly if my friend types the above but I don't want to give him ssh access to my machine, just let him proxy his browser though it.

Isham answered 8/5, 2009 at 22:4 Comment(2)
This question isn't programming related. Try serverfault.comEarlie
Same question at "Unix & Linux" Stackexchange: How to create reverse dynamic ssh port forwardingFructuous
V
41

For openssh, see the -R switch:

 -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 connec‐
         tion is forwarded over the secure channel, and a connection is
         made to host port hostport from the local machine.

Though there may be better solutions, you could create a SOCKS proxy at your friend's computer remotehost at port 24680 in the following manner. First, do

ssh -R 24680:localhost:12345 remotehost

And then, do

ssh -D 12345 localhost

Obviously, both sessions need to be kept alive simultaneously.

Valuator answered 8/5, 2009 at 22:13 Comment(1)
It's worth just adding a little explanation. So when you have CompA and CompB. The ssh -R 24680:localhost:12345 remotehost is run from CompA, and ssh -D 12345 localhost is also run from CompA. Creates a proxy for person B to use the SOCKS proxy on CompA. Person at CompB connects web browser to his(B's) local port 24680 and thus by proxy, uses the SOCKS proxy at CompA. Very Clever!Loreanloredana

© 2022 - 2024 — McMap. All rights reserved.