[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ssh_channel_open_session only works the first time called

On 11/3/21 11:23, Thorsten R. wrote:
On 11/2/21 15:46, Jakub Jelen wrote:
does your Cisco switch support more channels? You can try it for
example with openssh with connection multiplexing using

That's an interesting point. Did not know that multiplexing is possible.
But this is what I got:

First terminal
tr@LinuxMint19:~/$ ssh -o ControlMaster=yes -o ControlPath=~/.ssh/control-%h_%p_%r admin@
Password: ************

Second terminal
tr@LinuxMint19:~/$ ssh -o ControlPath=~/.ssh/control-%h_%p_%r admin@ mux_client_request_session: session request failed: Session open refused by peer

This is the failure to open a session channel.

Password: ************

OpenSSH implements fallback opening a new connection if the remote does not allow this.

Output on first terminal after second terminal connects:
gwswitch1#channel 3: open failed: resource shortage:

It seems that multiplexing is not possible on Cisco switches.
But now I am a little bit confused. I thought that calling


closes the shell and the session in a way that I can open a new one if needed.

Right. This closes the session channel, but connection is still open. With other servers, what you do might work just fine. With OpenSSH server, you can probably emulate this with "MaxSessions 1" in sshd_config.

What is the right way to open a SSH connection, open a terminal/shell, execute a few commands in it with


and close the shell without losing the connection?

This is not the most common use case. Generally, you want to execute command and exit or open a shell, execute commands, collect results and again exit the connection.

If you want to send more commands in some longer timespan, you will probably have to open a shell and handle the IO yourself as described in the following tutorial chapter:


Jakub Jelen
Crypto Team, Security Engineering
Red Hat, Inc.

ssh_channel_open_session only works the first time calledlibssh.org_ml@xxxxxxxxxxxxxxxxxxxx
Re: ssh_channel_open_session only works the first time calledJakub Jelen <jjelen@xxxxxxxxxx>
Re: ssh_channel_open_session only works the first time called"Thorsten R." <libssh.org_ml@xxxxxxxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org