Channel life span

David Goulet dgoulet at
Tue Oct 11 03:38:10 EST 2011

Hash: SHA1


Basic context for my questions:

Client (ssh) and server side (sshd) where the client use -L option for a
direct-tcpip channel and forward all requests. (All Linux and openssh version

$ ssh -L8080:<some-ip>:8181 ...

I noticed that when a third client send data to the local port (8080) used for
forwarding, a channel is created:

debug1: channel 1: new [direct-tcpip]
debug1: server_input_channel_open: confirm direct-tcpip
debug3: channel 1: waiting for connection

the request then pass through the tunnel, reply comes back and then the channel
receives an EOF (debug2: channel 1: rcvd eof). Both the ssh client and sshd
server agree on closing the channel and it's freed. Seems the normal behavior.

So, I did try, using a third part lib for SSH (libssh2), to recreate a
direct-tcpip channel and *keep* the channel open (not sending the EOF) in order
to send data later on (where the time between writes on the channel is unknown).
However, here is what's happening. After the first write to the channel, I read
the data back (reply), and keep the channel open (don't send the EOF on my
side). A quick 5 seconds later, I get this on the sshd (server side):

debug2: channel 1: read<=0 rfd 8 len 0
debug2: channel 1: read failed
debug2: channel 1: close_read
debug2: channel 1: input open -> drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug2: channel 1: input drain -> closed

and the channel is *not* usable again for transmission... I have to recreate one...

I did look at the openssh code to understand that behavior since it's not define
in the RFC 4254 that it should "close" after a timeout. I'm sure I am missing
something here that I'm doing wrong but I get this behavior even with the ssh
client in the openssh code tree.

So my questions are: Is it normal for channel to be open/close at *each*
different data transmission ?  and if not, how can I keep a channel alive for an
undefined period of time without having an EOF sent to me from the sshd server.

Thanks to all! I know it's long... but the problem is not that trivial to
explain by mail :P. Feel free to ask for more details!

Version: GnuPG v1.4.10 (GNU/Linux)


More information about the openssh-unix-dev mailing list