SSH fails immediately with `kex_exchange_identification: read: Connection reset by peer`.
AdvancedTroubleshootingSSH, sudo and authentication
Answer
Likely causes → The server closes the connection before the SSH banner: TCP wrappers/hosts.deny, fail2ban or a firewall resetting, MaxStartups exceeded (many unauthenticated connections), or sshd crashing per-connection.
Diagnose →
# server side
sudo journalctl -u sshd -n 50
sudo fail2ban-client status sshd 2>/dev/null
grep -i maxstartups /etc/ssh/sshd_config
cat /etc/hosts.deny 2>/dev/null
Fix → Unban the client IP (fail2ban-client set sshd unbanip 1.2.3.4), raise MaxStartups 30:30:100 if under scanning load, fix the crash shown in logs.
Prevent → Restrict SSH exposure so scanners can't exhaust MaxStartups.
More on SSH, sudo and authentication
`ssh deploy@server01` fails with `deploy@server01: Permission denied (publickey).`BeginnerPermissions on `~/.ssh` are correct, but you still get `Permission denied (publickey)` and the server log says `Authentication refused: bad ownership or modes for directory /home/deploy`.IntermediateKey auth fails only on RHEL with SELinux enforcing; the server logs show nothing unusual about modes.IntermediateAfter upgrading the client to a new OpenSSH, connections to an old appliance fail with `no matching host key type found. Their offer: ssh-rsa,ssh-dss`.IntermediateA user's RSA key stopped working against a new server: the server log says `userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms`.IntermediateSSH login takes 20–30 seconds before the password or key prompt appears.Intermediate