the internet's box_

log / Technology / Security

· error log #ssh #sshd #nas #openssh

SSH refuses you for 90 seconds after one failed connection

Symptom

Right after running ssh-keyscan against a NAS, every SSH attempt from the same machine failed for about a minute and a half. Then it worked again by itself. Nothing was wrong with keys, DNS or the network.

Cause

OpenSSH 9.8 and later ship PerSourcePenalties. When a connection drops before authentication finishes (which is exactly what ssh-keyscan does), sshd records a penalty against the source address. On this NAS the setting was crash:90: a pre-auth child that crashes earns the source address a 90-second penalty, and during that window sshd refuses new connections from it.

You can see it in the server's own config:

# sshd_config
PerSourcePenalties crash:90

Fix

  1. Stop retrying. Wait out the penalty.
  2. Don't use ssh-keyscan against that host. Put its host key in known_hosts once, from a normal login.
  3. If your own automation hits it, add a backoff longer than the penalty instead of a tight retry loop.

If you control the server and the penalty is too aggressive for your tooling, tune or remove the PerSourcePenalties line, and add PerSourcePenaltyExemptList for trusted addresses.

Lesson

A "connection refused" that fixes itself in about a minute is a rate limiter, not an outage.