使用 SSH 隧道接受传入连接

Ram*_*hum 5 ssh networking firewall tunnel

我试图使用 SSH 隧道来完成一些事情,但我尝试在谷歌上搜索“SSH 隧道”并找到有关各种不同场景的讨论,但不是我的场景。

我正在计算机 A 上工作。我可以通过 SSH 访问计算机 B。我希望计算机 B 运行需要连接到计算机 A 上的端口 40000 的程序 X。问题是,计算机 B 应用了严格的防火墙,而我没有不想修改。我想要的是利用我的能力,轻松地从计算机 A 到计算机 B 连接 SSH,使从 B 到 A 的连接成为可能。

这就是我的设想:我在计算机 A 上运行的程序 Y,它通过 SSH 连接到计算机 B,然后在计算机 B 上侦听端口 40000 上的连接,并通过 SSH 连接将它们转发到端口 40000然后我在计算机 B 上配置程序 X 来尝试连接到计算机 B 上的端口 40000,然后它实际上连接到计算机 A 上的端口 40000。

是否有现有的程序/SSH 配方可以执行此操作?

mmj*_*mjb 1

我猜你正在寻找 ssh 的 -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 connection is for-
         warded over the secure channel, and a connection is made to host
         port hostport from the local machine.
         [...]
Run Code Online (Sandbox Code Playgroud)