"ssh -D" can make a socks port at local machine, which pass the traffic to the remote, then to other places.

"ssh -L port:host:hostport", listen port at local machine, pass the traffic to "host:hostport" from the point of view of the remote machine.

"SSH -R port:host:hostport" is the counterpart of "ssh -L", which listen port at remote machine, and pass the traffic to "host:hostport" from the point of view of the local machine.

But what is the counterpart of "ssh -D", i.e., how to open a socks port at remote machine, which will pass the traffic to the local, then to other places?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

With -D & -L you have a way to communicate either way between the two machines.

So...

  • From the local machine, use -R to create a listenning port on the remote machine pointed at the local machine's sshd.
  • Use -D on the remote machine, pointed at the port you created above.

I "think" filling in the below will make it work...

ssh remotehost -R remoteport:localhost:localport "ssh -D 9050 localhost:remoteport"

'remotehost', 'remoteport' & 'localport' in the above need changing. A socks proxy will be formed on 9050.

link|improve this answer
Oh, looks like this was asked on SO: stackoverflow.com/questions/842021/… Only answer is the same idea. I'm sure one will work ;-) EDIT - yep, that one was more right than mine. I've patched mine up. – PriceChild Dec 23 '11 at 10:14
Actually, I did use this indirect method in my own situation. But in my firend's situation, he did not have the root privilege, so he can't have sshd service, he has only the OpenSSH client. So I want to figure out there is a direct method, but OpenSSH seems not...Thanks you the same – Berry Dec 23 '11 at 15:48
feedback

There is no facility for providing a reverse socks tunnel with OpenSSH, so you must run the ssh command providing the socks proxy on the "remote" machine.

If the remote machine cannot ssh into the local machine, create first a ssh connection from local to remote which forwards port 22 to e.g. 2222. Then the remote machine can ssh into the local machine on port 2222.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.