ssh -D <port> <username@server.com>; 但反过来呢?

use*_*862 24 ssh tunneling

是否可以设置具有动态端口转发的SSH隧道,如下所示:

ssh -D

但反过来呢?这就是说我想在我的本地机器上启动连接并在那里进行动态端口转发,让我的朋友将他的浏览器连接到隧道的另一端.

如果我的朋友输入上述内容,上面的工作完美,但我不想给他ssh访问我的机器,只是让他代理他的浏览器.

Ste*_*202 33

对于openssh,请参阅-R开关:

 -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.
Run Code Online (Sandbox Code Playgroud)

虽然可能有更好的解决方案,但您可以remotehost通过以下方式在朋友的计算机上以端口24680 创建SOCKS代理.首先,做

ssh -R 24680:localhost:12345 remotehost
Run Code Online (Sandbox Code Playgroud)

然后,做

ssh -D 12345 localhost
Run Code Online (Sandbox Code Playgroud)

显然,两个会议都需要同时保持活力.

  • 值得添加一点解释.所以当你有CompA和CompB时.`ssh -R 24680:localhost:12345 remotehost`从CompA运行,`ssh -D 12345 localhost`也从CompA运行.为B人创建代理以在CompA上使用SOCKS代理.CompB的人将Web浏览器连接到他的(B)本地端口24680,因此通过代理,在CompA使用SOCKS代理.非常聪明! (5认同)