fix(ssh): keep the key exchange off DH group16 #12

Merged
christianmanivong merged 1 commits from fix/ssh-kex-group14 into main 2026-10-30 08:23:29 +00:00
Owner

swt-l2-3-38 (SG2210P, firmware 5.30.0) flapped between online and offline on netOrk: 44 offline events in nine days, every poll failing with Paramiko: 'No existing session' error: try increasing 'conn_timeout'.

Cause. The switch offers diffie-hellman-group14-sha256 and diffie-hellman-group16-sha512 only, and paramiko picks group16. Measured from the poll worker (20 samples), that 4096-bit exchange takes 8.8 to 16.1 seconds, 8 of 20 over netmiko's 10-second conn_timeout. Paramiko's start_client stops waiting at the timeout without raising, the login then finds no finished key exchange and fails. The switches on 5.20.20 take 5 to 6 seconds, close enough to fail now and then too.

group16 group14
.38 (5.30.0) 8.8 / 16.9 / 8.8 s 1.5 / 1.5 / 1.6 s
.35 (5.20.20) 5.6 / 5.5 / 5.2 s 1.7 / 1.0 / 1.1 s

Change. open() disables group16 by default; a disabled_algorithms in optional_args still wins. The netmiko arguments move into _ssh.py, so tplink_jetstream.py stays at its recorded 2029 lines.

Checked. Tests (new tests/unit/test_ssh_kex.py), ruff, mypy --strict on _ssh.py. Live against .38 through netOrk's own connection path: open + enable in 2.1 seconds, five times in a row.

swt-l2-3-38 (SG2210P, firmware 5.30.0) flapped between online and offline on netOrk: 44 offline events in nine days, every poll failing with `Paramiko: 'No existing session' error: try increasing 'conn_timeout'`. **Cause.** The switch offers `diffie-hellman-group14-sha256` and `diffie-hellman-group16-sha512` only, and paramiko picks group16. Measured from the poll worker (20 samples), that 4096-bit exchange takes 8.8 to 16.1 seconds, 8 of 20 over netmiko's 10-second `conn_timeout`. Paramiko's `start_client` stops waiting at the timeout without raising, the login then finds no finished key exchange and fails. The switches on 5.20.20 take 5 to 6 seconds, close enough to fail now and then too. | | group16 | group14 | |---|---|---| | .38 (5.30.0) | 8.8 / 16.9 / 8.8 s | 1.5 / 1.5 / 1.6 s | | .35 (5.20.20) | 5.6 / 5.5 / 5.2 s | 1.7 / 1.0 / 1.1 s | **Change.** `open()` disables group16 by default; a `disabled_algorithms` in `optional_args` still wins. The netmiko arguments move into `_ssh.py`, so `tplink_jetstream.py` stays at its recorded 2029 lines. **Checked.** Tests (new `tests/unit/test_ssh_kex.py`), ruff, mypy --strict on `_ssh.py`. Live against .38 through netOrk's own connection path: open + enable in 2.1 seconds, five times in a row.
christianmanivong added 1 commit 2026-10-30 08:17:59 +00:00
fix(ssh): keep the key exchange off DH group16
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m7s
driver / lowest (pull_request) Successful in 28s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 2m25s
driver / publish (pull_request) Skipped
d14c11e991
The switch offers diffie-hellman-group14-sha256 and group16-sha512 only,
and paramiko picks group16. On an SG2210P with firmware 5.30 that 4096-bit
exchange takes 9 to 16 seconds, against netmiko's 10-second conn_timeout:
paramiko then tries to log in on a transport whose key exchange has not
finished and fails with "No existing session", so every other poll failed
and netOrk flapped the switch between online and offline. group14 takes
1.5 seconds.

group16 is now disabled by default; a disabled_algorithms passed in
optional_args still wins. The netmiko arguments move into _ssh.py, so
tplink_jetstream.py keeps its recorded length.
christianmanivong merged commit 3034ee0881 into main 2026-10-30 08:23:29 +00:00
christianmanivong deleted branch fix/ssh-kex-group14 2026-10-30 08:23:29 +00:00
Sign in to join this conversation.