gpt4 book ai didi

networking - 使用 SSH 隧道接受传入连接

转载 作者:行者123 更新时间:2023-12-03 16:42:49 25 4
gpt4 key购买 nike

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

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

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

是否有一个现有的程序/SSH 配方可以做到这一点?

最佳答案

我猜您正在寻找 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.
[...]

关于networking - 使用 SSH 隧道接受传入连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31189773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com