Channels on SSH-2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
    I am confused about channels in SSH-2. The standard says that
when the client wishes to open a channel it sends a SSH_MSG_CHANNEL_OPEN
message, containing a sender channel field, which is an integer to
identify that channel.

    The server is supposed to reply with
SSH_MSG_CHANNEL_OPEN_CONFIRMATION, which contains two channel
identifiers: recipient and sender. Here is where the confusion begins.
The standard (RFC 4254, section 5.1) says

    "The 'recipient channel' is the channel number given in the
original open request, and 'sender channel' is the channel number
allocated by the other side."

This would seem to imply that 'recipient channel' is here whatever was in
the sender channel field of the matching SSH_MSG_CHANNEL_OPEN message
sent by the client. I would have thought that 'sender channel' must be
whatever channel identifier the server has assigned to this channel -
which may, or may not, be the same as that assigned by the client.

    Is this the correct interpretation? What is making me doubt is
that the quotation above seems to imply that 'recipient channel' and
'sender channel' are one of the same - which is of course silly (why
would we need to call them 'recipient' and 'sender' if they are the same?)

Re: Channels on SSH-2

Quoted text here. Click to load it

Yes. `Recipient' and `sender' here denote the recipient and sender
of _each individual SSH message_. So whenever I send you a message
about some channel, the sender field indicates my reference number
for the channel (because I'm the one sending _this particular
message_), and the recipient field indicates your reference number
(because you're the one receiving this message). When you reply to
me, you are the sender and I am the recipient, so the two roles are
swapped round and so are the reference numbers.

Quoted text here. Click to load it

Have you got confused between `sender' and `server' here, perhaps?

The advantage of doing it this way is that the channel management
code can be shared between an SSH client and an SSH server without
having to flip round the meanings of the fields based on some sort
of state bit. Whether I'm a client or a server, I always put my own
reference number in the sender field of outgoing messages, and
expect to find my own reference number in the recipient field of
incoming messages.
Simon Tatham         "A defensive weapon is one with my finger on the

Re: Channels on SSH-2

    OK, thanks; that clarifies things all right. I believe that the
relevant section of the standard ought to have been better written though.

On Tue, 12 Jun 2007 17:19:50 +0100, Simon Tatham wrote:

Quoted text here. Click to load it

Site Timeline