For NetOrk/netork#1800. OpenSSH 9.8+ (PerSourcePenalties) penalises a source whose connections do not authenticate, and then drops every connection from it. A security scanner's probes earn the managing client exactly that. On netOrk's test server, the post-provision Ansible run of a new Ubuntu 26.04 VM was dropped this way (sshd: penalty of 16 seconds for penalty: connections without attempting authentication).
Reads the address the host sees the managing client at ($SSH_CONNECTION) and adds it to the PerSourcePenaltyExemptList sshd uses now. The host's own entries stay.
Writes it to its own drop-in, /etc/ssh/sshd_config.d/00-netork-penalty-exempt.conf.
Writes nothing to an sshd without penalties. OpenSSH 9.2 (Debian 12) rejects the directive (sshd -t rc 255) and would not start. Checked in containers, also against Debian 13's OpenSSH 10.0 (persourcepenaltyexemptlist none by default, first value wins).
Does nothing when the address is already exempt, or when sshd_config does not include the drop-in directory. The result says so.
Then the same checks as harden_ssh_server: sshd -t, sshd -T shows the address, reload, verify. On any failure the previous state goes back. _apply_or_restore is now shared by both methods (an ignored() callback and a success message).
A connection sshd closes before its banner ("Error reading SSH protocol banner", also when wrapped) is tried again after 1, 3, 7 and 15 s, 26 s in all.
A failed login, a timeout or a closed port is not retried.
HostKeyCheck.connect uses it, so every paramiko driver that connects through it gets it.
Tests
tests/test_ssh_penalties.py: parsing against the real Debian 13 output, and the mixin against a fake host that resolves first-value-wins across the main config and the drop-ins. Cases: no penalties, already exempt, no Include, rejected by sshd -t, shadowed by an earlier drop-in, failed new session, no client address.
tests/test_ssh_refused.py: the classifier, the backoff, and a real paramiko connect against a TCP server that drops the first two connections the way a penalised source sees it.
All 921 tests green. ruff and mypy clean. Coverage of ssh_server 96 %, of ssh_host_keys 98 %.
No version bump: the entries are under Unreleased in the CHANGELOG.
Next
napalm-linux wraps its netmiko ConnectHandler in retry_refused.
netOrk calls exempt_from_ssh_penalties during a new VM's bootstrap and in the SSH fix.
For NetOrk/netork#1800. OpenSSH 9.8+ (`PerSourcePenalties`) penalises a source whose connections do not authenticate, and then drops every connection from it. A security scanner's probes earn the managing client exactly that. On netOrk's test server, the post-provision Ansible run of a new Ubuntu 26.04 VM was dropped this way (sshd: `penalty of 16 seconds for penalty: connections without attempting authentication`).
## Added
- **`OpenSshServerMixin.exempt_from_ssh_penalties(verify=, log=)`**
- Reads the address the host sees the managing client at (`$SSH_CONNECTION`) and adds it to the `PerSourcePenaltyExemptList` sshd uses now. The host's own entries stay.
- Writes it to its own drop-in, `/etc/ssh/sshd_config.d/00-netork-penalty-exempt.conf`.
- **Writes nothing to an sshd without penalties.** OpenSSH 9.2 (Debian 12) rejects the directive (`sshd -t` rc 255) and would not start. Checked in containers, also against Debian 13's OpenSSH 10.0 (`persourcepenaltyexemptlist none` by default, first value wins).
- Does nothing when the address is already exempt, or when sshd_config does not include the drop-in directory. The result says so.
- Then the same checks as `harden_ssh_server`: `sshd -t`, `sshd -T` shows the address, reload, `verify`. On any failure the previous state goes back. `_apply_or_restore` is now shared by both methods (an `ignored()` callback and a success message).
- Helpers: `parse_penalty_exemptions`, `client_address`, `is_exempt`, `render_penalty_dropin`, `PENALTY_DROPIN_PATH`, `SshPenaltyExemption`.
- **`retry_refused(attempt, waits=, sleep=)` / `refused_before_banner(exc)`** (`ssh_host_keys`)
- A connection sshd closes before its banner ("Error reading SSH protocol banner", also when wrapped) is tried again after 1, 3, 7 and 15 s, 26 s in all.
- A failed login, a timeout or a closed port is not retried.
- `HostKeyCheck.connect` uses it, so every paramiko driver that connects through it gets it.
## Tests
- `tests/test_ssh_penalties.py`: parsing against the real Debian 13 output, and the mixin against a fake host that resolves first-value-wins across the main config and the drop-ins. Cases: no penalties, already exempt, no Include, rejected by `sshd -t`, shadowed by an earlier drop-in, failed new session, no client address.
- `tests/test_ssh_refused.py`: the classifier, the backoff, and a real paramiko connect against a TCP server that drops the first two connections the way a penalised source sees it.
- All 921 tests green. ruff and mypy clean. Coverage of `ssh_server` 96 %, of `ssh_host_keys` 98 %.
No version bump: the entries are under Unreleased in the CHANGELOG.
## Next
- napalm-linux wraps its netmiko `ConnectHandler` in `retry_refused`.
- netOrk calls `exempt_from_ssh_penalties` during a new VM's bootstrap and in the SSH fix.
OpenSSH 9.8+ penalises a source whose connections do not authenticate --
a scanner's probes -- and then drops every connection from it, the
managing client's included.
- OpenSshServerMixin.exempt_from_ssh_penalties puts the address the host
sees the client at ($SSH_CONNECTION) into PerSourcePenaltyExemptList,
next to the host's own exemptions, in its own drop-in. Only where sshd
has the penalties (an older one refuses the directive) and includes the
drop-in directory; checked with sshd -t, sshd -T and a new session, and
taken back on any failure. The check-and-restore step of
harden_ssh_server is shared for it.
- retry_refused tries a connection again after 1, 3, 7 and 15 s while
sshd closes it before its banner; HostKeyCheck.connect uses it.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
For NetOrk/netork#1800. OpenSSH 9.8+ (
PerSourcePenalties) penalises a source whose connections do not authenticate, and then drops every connection from it. A security scanner's probes earn the managing client exactly that. On netOrk's test server, the post-provision Ansible run of a new Ubuntu 26.04 VM was dropped this way (sshd:penalty of 16 seconds for penalty: connections without attempting authentication).Added
OpenSshServerMixin.exempt_from_ssh_penalties(verify=, log=)$SSH_CONNECTION) and adds it to thePerSourcePenaltyExemptListsshd uses now. The host's own entries stay./etc/ssh/sshd_config.d/00-netork-penalty-exempt.conf.sshd -trc 255) and would not start. Checked in containers, also against Debian 13's OpenSSH 10.0 (persourcepenaltyexemptlist noneby default, first value wins).harden_ssh_server:sshd -t,sshd -Tshows the address, reload,verify. On any failure the previous state goes back._apply_or_restoreis now shared by both methods (anignored()callback and a success message).parse_penalty_exemptions,client_address,is_exempt,render_penalty_dropin,PENALTY_DROPIN_PATH,SshPenaltyExemption.retry_refused(attempt, waits=, sleep=)/refused_before_banner(exc)(ssh_host_keys)HostKeyCheck.connectuses it, so every paramiko driver that connects through it gets it.Tests
tests/test_ssh_penalties.py: parsing against the real Debian 13 output, and the mixin against a fake host that resolves first-value-wins across the main config and the drop-ins. Cases: no penalties, already exempt, no Include, rejected bysshd -t, shadowed by an earlier drop-in, failed new session, no client address.tests/test_ssh_refused.py: the classifier, the backoff, and a real paramiko connect against a TCP server that drops the first two connections the way a penalised source sees it.ssh_server96 %, ofssh_host_keys98 %.No version bump: the entries are under Unreleased in the CHANGELOG.
Next
ConnectHandlerinretry_refused.exempt_from_ssh_penaltiesduring a new VM's bootstrap and in the SSH fix.