通过外部服务器在防火墙后面的两台计算机上进行 SSH 连接

发布于 2024-10-17 20:13:47 字数 238 浏览 1 评论 0原文

我在一所大学拥有两台电脑。它们都位于某种防火墙等后面,这不允许我通过网络直接连接它们。他们都可以通过 SSH 公用计算机,但我不知道如何从一台计算机到另一台计算机。我还经营一个小网站。我的问题是,我可以使用我网站的公共地址以某种方式连接我的两台计算机,而不会让所有信息流过我的网站并占用我的所有带宽吗?理想情况下,我想在两台计算机之间创建一个 ssh 隧道。

我已经尝试过 Hamachi,它在 Mac 上运行得不太好,我想要对连接有更多的控制。

I own two computers at a University. Both of them are behind some sort of firewall etc. which disallows me to directly connect them over the network. They can both SSH public computers, but I can't figure out how to ssh from one to the other. I also run a small website. My question is, can I use the public address of my website to somehow connect my two computers without all the information flowing through my website and eating all my bandwidth? Ideally I'd like to create a ssh tunnel between my two computers.

I've already tried Hamachi, it doesn't play well with macs anymore and I'd like more control over the connection.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2024-10-24 20:13:48

假设您想通过 ServerC(您的公共服务器)从 MachineA 到 MachineB(都在大学)。

您需要在 ServerC 和 MachineB 上运行 sshd。

运行以下命令,假设您的 sshd 正在侦听 MachineB 和 ServerC 上的端口 22:

# Forward incoming connections from ServerC:22000 to MachineB:22
(on MachineB) ssh -R22000:127.0.0.1:22 -N user@ServerC
# Forward incoming connections from 127.0.0.1:22000 to ServerC:22000
(on MachineA) ssh -L22000:127.0.0.1:22000 -N user@ServerC
# Establish the link between MachineA and MachineB
(on MachineA) ssh -p 22000 [email protected]

此方法只需要访问端口 22,如果您的大学代理是邪恶的,您可以轻松地将其更改为 80 或 443。

Let's assume you want to ssh from MachineA to MachineB (both at the university) by going through your ServerC (your public server).

You will need to run sshd on the ServerC and on MachineB.

Run the following commands, assuming your sshd is listening on port 22 on MachineB and ServerC :

# Forward incoming connections from ServerC:22000 to MachineB:22
(on MachineB) ssh -R22000:127.0.0.1:22 -N user@ServerC
# Forward incoming connections from 127.0.0.1:22000 to ServerC:22000
(on MachineA) ssh -L22000:127.0.0.1:22000 -N user@ServerC
# Establish the link between MachineA and MachineB
(on MachineA) ssh -p 22000 [email protected]

This method only needs access to the port 22, and you can easily change this to 80 or 443 if your university proxy is evil.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文