Allright after studying the RFC's again I believe that this is the right way to 
do it:
1. Start SSH session2. Request listening on remote port3. While Forever        
1. Wait untill incoming channel and load in an ssh_channel        2. while 
connection not closed                  1. Read reverse channel and write to 
Local Socket                  2. Read Local socket and write to reverse channel 
       3. Close Channel 
That is exactly what my while loop does. After I have closed the channel it 
starts waiting for a new one. When a connection arrives my code continues to 
the loop where it starts forwarding the data between the channel and the 
socket, but there there never seems to be any data on the channel. This has 
kept me occupied for over a day now, and it's really weird that everything 
works fine on the first connection but not on the second.
If I am missing a step in the list above please tell me. If there is a mistake 
in my code I will probably be able to figure it out myself.
Kind regards, Lars van Ruiten  > From: [email protected]
> To: [email protected]
> Subject: Re: Quick question
> Date: Thu, 8 Oct 2015 10:34:16 +0200
> 
> On Thursday 08 October 2015 07:12:49 lars van ruiten wrote:
> > Hi,Hoping that someone will answer this time: here is a little problem I've
> > been having.I am writing an application that creates a functional reverse
> > SSH tunnel. The tunnel is working, but in order to connect a second time I
> > have to restart my program that starts the SSH connection an creates the
> > tunnel.
> 
> Yes, that's by design. I'm sure you read the RFCs to understand how SSH 
> channels are working, didn't you?
> 
> You need to cleanup the channel and create a new one.
> 
> -- 
> Andreas Schneider                   GPG-ID: CC014E3D
> www.cryptomilk.org                [email protected]
> 
                                          

Reply via email to