agebrock / tunnel-ssh

Easy ssh tunneling
MIT License
354 stars 95 forks source link

Multiple ports forwards #110

Open Dragonox77 opened 1 year ago

Dragonox77 commented 1 year ago

Hi,

Is there a way to have multiple ports forwarding with this lib ?

Thank you

agebrock commented 1 year ago

I was asked that question before. I guess you want to open multiple ports on your local machine as well. So you would need multiple TCP servers.

In that case I simply advice to create multiple instances of the tunnel.

If you have something different in mind, please provide a usage example.

Thanks !

Dragonox77 commented 1 year ago

Hi, Many thanks for this answer;

I was thinking of transforming the tunnelOptions config variable into an array, and iterating it so you could create as much as tunnels as you need internaly, and call "conn.forwardOut" (line 80) for every entries.

What do you think ?

Thank you again

agebrock commented 1 year ago

This came up in the 4.x version already. The problem I see is that you need to open the ports on your local machine as well.

So for the setup you describe, I guess we need multiple tcp server, multiple forwards but only one ssh connection.

In fact I am having kind of the same requirement in one of my experiments where I would like to bind all ports from a kubernetes (or docker cluster) from a remote machine to my local one.

I think that goes into the same direction as your request.

I am reviewing the code one more time, and see how we could prepare the lib to do such thing.

Thanks for your input.