Subject: Re: SSH Port Forwarding Disconnection Issue

Re: SSH Port Forwarding Disconnection Issue

From: Peter Stuge <>
Date: Thu, 26 Mar 2020 21:14:03 +0000


Riddhi K wrote:
> I am using libssh2 for my iOS SSH Client application. By the reference of
> direct_tcpip.c and tcpip_forward.c I’ve implemented Local and Remote Port
> Forwarding. The connection is working fine. But the issue is, after loading
> one request connection terminates automatically.
> Is there any solution or any suggestions regarding this issue?

Those example programs intentionally demonstrate only the minimum that
is required to forward a single connection through SSH.

If you want to support multiple connections then you have to write
the code for that yourself, and to do so you will probably have to
spend a bit of time on studying that example code, so that you can
modify it to match your requirement.

The challenges involved in forwarding multiple connections are nearly
if not completely unrelated to the SSH forwarding itself, so they are
not really in scope for libssh2.

That said, if you can write a minimal example which processes multiple
forwarded connections, then please do propose it to be added as a
example in libssh2. Remember to keep the same style as existing code.


Received on 2020-03-26