Fix Connection to Enterasys B2 Switch #266

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@egroeper
Contributor

Connecting to an Enterasys B2 Switch (using demo_simple.py) for an
interactive shell doesn't work:

Connected. Getting Shell...
DEBUG:paramiko.transport:[chan 1] Max packet in: 34816 bytes
DEBUG:paramiko.transport:[chan 1] Max packet out: 16384
bytes
INFO:paramiko.transport:Secsh channel 1 opened.
ERROR:paramiko.transport:Channel request for unknown
channel 0
*** Caught exception: <class 'paramiko.SSHException'>: Channel closed.

The channels gets opened with index 1 on client
(paramiko) side and index 0 on server (switch)
side.
Probably the switch doesn't support this and
replies to the pty request with a wrong channel
id. Because of that paramiko closes the
connection.

This can be solved (or worked around) easily by
initialising _channel_counter with 0.
This is what other clients, like openssh do.

I don't see a problem with initialising this
counter with 0.
Would this be acceptable?

@lndbrg
Contributor
lndbrg commented Mar 4, 2014

I guess this works well with other normal hosts and devices? If so this should be a no brainer.

@egroeper
Contributor
egroeper commented Mar 7, 2014

Yes. Here it works well with other hosts and devices.

@egroeper egroeper Fix Connection to Enterasys B2 Switch
Connecting to an Enterasys B2 Switch (using demo_simple.py) for an
interactive shell doesn't work:

    Connected. Getting Shell...
    DEBUG:paramiko.transport:[chan 1] Max packet in: 34816 bytes
    DEBUG:paramiko.transport:[chan 1] Max packet out: 16384
    bytes
    INFO:paramiko.transport:Secsh channel 1 opened.
    ERROR:paramiko.transport:Channel request for unknown
    channel 0
    *** Caught exception: <class 'paramiko.SSHException'>: Channel closed.

The channels gets opened with index 1 on client
(paramiko) side and index 0 on server (switch)
side.
Probably the switch doesn't support this and
replies to the pty request with a wrong channel
id. Because of that paramiko closes the
connection.

This can be solved (or worked around) easily by
initialising _channel_counter with 0.
This is what other clients, like openssh do.

I don't see a problem with initialising this
counter with 0.
a805efb
@egroeper
Contributor

I rebased my feature branch to ease up merging.
I don't think the current build problems have to do with my fix.

@lndbrg
Contributor
lndbrg commented Dec 13, 2014

I re-triggered the build.

@bitprophet
Member

@lndbrg Dunno if this is really 'high priority', how many users are targeting this specific type of switch? ;)

Still sounds ok, needs a changelog entry for sure though, moderate chance some folks are relying on (or at least aware of) the current 1-indexing and may have a confuse when it changes. I can do this when I prep for release.

@bitprophet bitprophet modified the milestone: 2.0, 1.15.2 et al Dec 15, 2014
@lndbrg
Contributor
lndbrg commented Dec 16, 2014

I REJECT THE NOTION THAT I ACTUALLY ADDED THAT LABEL!

@bitprophet
Member

Confirmed this change doesn't appear to break Paramiko or Fabric's test suites.

Also dug into the OpenSSH source and confirmed that it begins channel numbering at 0: variable init in loop at 0 here and assignment to 'self' (channel id) here (definition of 'self' here)

@bitprophet bitprophet added a commit that referenced this pull request Dec 17, 2014
@bitprophet bitprophet Changelog re #266 522c480
@bitprophet
Member

Cherry-picked back to bugfix branch, which Github can't follow. Merged to master now. Closing!

@bitprophet bitprophet closed this Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment