Channel life span

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

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
5.9p1).

$ 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!

Cheers!
David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJOkx9yAAoJEELoaioR9I02drwIAMh9mYLpJYaM3ss5S7cD5BvD
J6/SzDMOgceYijVqgU5JIZJj2l9H7rwDvwZAj178cUv5DSjfHfF1X1WEGALTI6EA
son9usUM0zhkJh+Nsg4Wl2wWPpi0UOLmfQ4yb4dMkxpAU8QrcVCYE0PqCjSVRdcZ
A2lOZdAjEvwnR4QJhiRC2Yxj+h88x/wo0v03ysW9M0bTUj/bLCD8EaNlkopOU1+I
xGDhhcTDpq+e2RYf2wMWBzRRBhqEcNpaUqOSCkiKw4wfdq+8m3UmClRUBngTuPp0
y+Ldb7L81Vtt0niCuIMbj4qjxTSR9KxBlD0j2RMz/w4TCJhDwDRJtjFrx82GLRE=
=jdEM
-----END PGP SIGNATURE-----


More information about the openssh-unix-dev mailing list