Interview Prep/Linux/SSH, sudo and authentication

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.

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication