SSH隧道复杂问题
对于一个编程项目,我必须做一些奇怪的设置。现在,首先,我在两台服务器上都有 root 权限,并且我认为 ssh 隧道是最好的方法(如果您有更好的想法,请随时告诉我)
我必须编写一个运行在IRC 服务器。这并不困难,但 IRC 服务器只能在本地主机上访问。所以我必须先通过 ssh 连接到盒子,然后使用 irssi 或类似的方式连接到 localhost:6667
现在我尝试从第二台服务器(我一直在运行 irssi)建立 ssh 隧道,然后通过隧道连接到服务器并通过隧道使用 localhost,类似于:
ssh -f user@server2 -L 2000:server2:6667 -N
现在,当我使用 irssi 连接到 localhost:2000 时,这不能按预期工作。我不明白为什么,你有什么提示吗?如果你能帮助我,我会很高兴。
问候
for a programming project I have to do some strange setup. Now, first of all, I have root rights on both servers, and I think an ssh tunnel is the best way (if you have a better idea, please feel free to tell me)
I have to write a piece of software running on an IRC server. That is not difficult, but the IRC server is only reachable on localhost. So I have to ssh to the box first and then use irssi or similar to connect to localhost:6667
Now I tried to do an ssh-tunnel from a second server (where I have irssi running all the time) and then tunnel to the server and use localhost through the tunnel, something like:
ssh -f user@server2 -L 2000:server2:6667 -N
Now this is not working as expected when I use irssi to connect to localhost:2000. I don't understand why, do you have any hint? I would be glad if you could help me.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请记住,您通过隧道到达的地址(在您的例子中为 server2:6667)是从目的地的角度来看的。例如:我有一个安装了 ssh 的 VPS。如果我执行 ssh -f user@vps -L 2000:localhost:3306 ,我可以连接到在其上运行的 MySql 服务器(仅在环回接口上侦听)。
因此,假设 IRC 服务器在 server2 上运行,您应该这样做:
然后,您可以使用 IRC 客户端连接到 localhost:2000(在 server1 上),并获得与在 server2 上运行的 IRC 服务器的连接。
Remember that that address you tunnel to (server2:6667 in your case) is from the point of view of the destination. For example: I have a VPS running with ssh installed. If I do
ssh -f user@vps -L 2000:localhost:3306
I can connect to the MySql server running on it (which is only listening on the loopback interface).So assuming the IRC server is running on server2 you should do:
You can then connect to localhost:2000 (on server1) with your IRC client and get a connection to the IRC-server running on server2.