SSH reliability
Port 22 on vm-nri-www is open to one operator address only, by key only —
see SSH authentication. This
page covers keeping that connection reliable.
Connecting to a server where port 22 is restricted to one address has a
specific, recurring failure mode, documented at length in
Linux Server Setup/SSH Access and Anti-Lockout in the Compendium vault. The
short version: a stalled connection sits in sshd’s pre-authentication queue
until LoginGraceTime expires, parallel sessions stack more, and once
MaxStartups is reached new connections are dropped. Retrying harder keeps the
queue full.
The server-side drop-in at /etc/ssh/sshd_config.d/50-operator.conf:
PerSourcePenaltyExemptList <operator address>LoginGraceTime 30MaxStartups 50:30:200Verify with sshd -T | grep -iE 'maxstartups|logingracetime|persourcepenalt'.
The client side matters more than the server side, and the fix that actually
works is multiplexing — one shared connection instead of bursts of one-shot
sessions. The ~/.ssh/config entry:
Host vm-nri-www nri-azure HostName <vm-address> User azureuser ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h-%p ControlPersist 4h ServerAliveInterval 15 ServerAliveCountMax 2 ConnectTimeout 15When SSH is unreachable, az vm run-command invoke runs commands on the VM as
root through the Azure agent, over the Azure control plane rather than the
network. It is the recovery path, and the reason it is worth knowing who holds
Contributor rights.