SSH tunnel Complex Problem

2019-06-05 19:18发布

问题:

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

回答1:

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@server1:~$ ssh -f you@server2 -L 2000:localhost:6667 -N

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



标签: bash ssh tunnel