SSH隧道复杂问题 [英] SSH tunnel Complex Problem

查看:93
本文介绍了SSH隧道复杂问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于编程项目,我必须进行一些奇怪的设置.现在,首先,我在两台服务器上都具有root权限,我认为ssh隧道是最好的方法(如果您有更好的主意,请随时告诉我)

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)

我必须编写一个在IRC服务器上运行的软件.这并不困难,但是IRC服务器只能在localhost上访问.所以我必须先SSH到盒子,然后使用irssi或类似的东西连接到localhost:6667

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

现在,我尝试从第二台服务器(一直在运行irssi的服务器)上执行ssh隧道,然后通过隧道将其隧道连接到服务器并使用localhost,例如:

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  

现在,当我使用irssi连接到localhost:2000时,此功能无法按预期工作.我不明白为什么,您有什么提示吗?如果您能帮助我,我会很高兴.

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.

致谢

推荐答案

请记住,从目的地的角度来看,您隧道传输到的地址(在您的情况下为server2:6667).例如:我有一个运行ssh的VPS.如果执行 ssh -f user @ vps -L 2000:localhost:3306 ,我可以连接到运行在它上面的MySql服务器(仅在回送接口上监听).

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).

因此,假设IRC服务器在server2上运行,您应该这样做:

So assuming the IRC server is running on server2 you should do:

you@server1:~$ ssh -f you@server2 -L 2000:localhost:6667 -N

然后,您可以使用IRC客户端连接到localhost:2000(在server1上),并获得与在server2上运行的IRC服务器的连接.

You can then connect to localhost:2000 (on server1) with your IRC client and get a connection to the IRC-server running on server2.

这篇关于SSH隧道复杂问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆