ultimate cause
ultimate cause

Reputation: 2294

Multiple channels in a single SSH session

I am debugging OpenSSH code where it seems multiple channels have been allocated on single SSH session (single connected child server).

My queries could be naive here:

  1. Under what conditions can multiple channels be opened?

  2. What are the SSH message flows which lead to multiple channels? A message flow chart will be very helpful.

  3. Is it correct to free channels[0] in the case below?

(gdb) p channels[0]
$1 = (Channel *) 0xb0f33e20
(gdb) p channels[0]->rfd
$2 = 0xd
(gdb) p channels[0]->efd
$3 = 0xffffffff
(gdb) p channels[0]->wfd
$4 = 0xffffffff
(gdb) p channels[1]->wfd
$5 = 0x9
(gdb) p channels[1]->efd
$6 = 0xffffffff
(gdb) p channels[1]->rfd
$7 = 0x9

Upvotes: 2

Views: 2433

Answers (1)

Jakuje
Jakuje

Reputation: 25966

Under what conditions can multiple channels be opened?

Every channel is either X11 forwarding, TCP port forwarding (there might be more types), UNIX domain socket forwarding (or ssh-agent socket) or MUX proxy. Consulting source code describing the types is a good start. They are opened, if the client requests them using command-line options (-X, -L, -R, -D, -A, ...) which are described in the manual page for ssh.

What are the SSH message flows which lead to multiple channels? A message flow chart will be very helpful.

If you will run the OpenSSH client and/or server in debug mode (LogLevel DEBUG3), you will get a lot of useful information what messages are being exchanged for various use cases.

Is it correct to free channels[0] in the case below?

Most probably not, but it is not clear what you ask here and what is the context. That is obviously valid channel with read file descriptor pointing to FD 0x0D so you might expect there will be something to read at some point.

Upvotes: 2

Related Questions