in reply to Re^2: Net::OpenSSH multiple sessions and legacy KEX problem
in thread Net::OpenSSH multiple sessions and legacy KEX problem

It seems the remote server has a broken SSH implementation:
debug3: send packet: type 90 # This was the request to open a new channel (SSH_MSG_CHANNEL_OPEN) debug3: receive packet: type 91 debug2: channel 1: open confirm rwindow 12288 rmax 512 # That was the Ok response (SSH_MSG_CHANNEL_OPEN_CONFIRMATION) debug3: receive packet: type 1 Received disconnect from 10.10.3.6 port 22:2: Disconnect Protocol erro +r # And then, suddenly, an unexpected disconnect message saying "Prot +ocol error"

It is not completely uncommon for some SSH implementations, specially those found in network equipment, to not support more than just one session per connection or requiring it to be open at some specific time (i.e. just after the transport layer becomes ready). There is not much you can do to work-around these issues.

Net::SSH::Any has the Ssh_Cmd backend which uses ssh in the common way, but then you can not combine it with Net::Telnet. At least, not easily. Net::SSH::Any provides the pipe method, which returns an object emulating a socket... maybe the emulation is good enough for Net::Telnet... I don't know, never tried!

Replies are listed 'Best First'.
Re^4: Net::OpenSSH multiple sessions and legacy KEX problem
by pwlodawi (Initiate) on Feb 16, 2018 at 16:08 UTC

    Just to conclude, there is no way to use Net::OpenSSH with only one session ?

    OpenSSH command line client opens only one session and it works even with this buggy implementation.

    You are right that router's implementation is bad but I can do nothing about that. It's legacy device and there are no chances for new fixed version. I don't have to use Net::Telnet. Having it would make migrating some scripts easier but it's not a must have.

    What I don't like in Net::SSH::Any::Backend::Ssh_Cmd it that is going to open a new connection for each command. Right ?

    Anyway, thanks for your help

    Pawel

      Just to conclude, there is no way to use Net::OpenSSH with only one session?

      You are not doing anything fanciful, the basic stuff just doesn't seem to work. I can not imagine how you could avoid that issue.

      What I don't like in Net::SSH::Any::Backend::Ssh_Cmd it that is going to open a new connection for each command. Right?

      Not exactly. Ssh_Cmd runs a new connection for every session. Usually, when the remote side is some server running some Unix/Linux, you run a command per session but in the case of network equipment frequently they provide some custom shell that requires running a conversation against it and executing all commands in the same session. The fact that you want to use Net::Telnet hints in that direction.