KatInterview

Diagnose an SSH Service That Stopped Accepting Connections

System DesignModel answer
MediumModel answerSystem Designlinuxnetworkingssh

Last updated

Design a layered, evidence-driven diagnostic plan to find why an SSH daemon is unreachable, from the client all the way down to daemon logs.

Scenario

You are on call when a monitoring alert fires: a critical internal host, prod-exec-04.infra, is no longer accepting SSH connections. Engineers attempting to connect see either Connection refused or Connection reset by peer. Out-of-band access (IPMI or serial console) is still available, but all remote shell access is gone.

Walk through a complete, layered troubleshooting plan to pinpoint the root cause. For each step, describe the exact command or telemetry source you would use, the hypothesis it is testing, and — crucially — what the result conclusively proves versus what uncertainty remains.

What your answer should cover

1. Client and transport layer (outside-in)

  • How do you distinguish between the three main failure signatures: silent timeout, an active TCP RST, and a reset that happens after the TCP handshake already completed?
  • What client-side tools would you use (ssh -vvv, nc, tcpdump, mtr/traceroute), and what does each failure mode rule out?

2. Host network and firewall layer (via console)

  • How would you verify interface state, routing, and packet-filter rules (iptables, nftables, firewalld)?
  • How do you tell apart a silent packet drop from an active reject at the firewall level?

3. Socket and process layer

  • How do you confirm whether sshd is running and what address/port it is bound to?
  • What would you check if the daemon exists but appears hung or is refusing new connections despite being technically alive?

4. Authentication and daemon logging

  • Where do you look for log evidence once you have confirmed the daemon received the connection?
  • What less-obvious configuration issues (TCP wrappers, PAM, SELinux/AppArmor, disk/inode exhaustion) could cause a connection that completes the TCP handshake to fail immediately after?

A strong answer states the hypothesis before each check, explains what the observation proves, and identifies the residual ambiguity. Listing tools without reasoning will not score well.

Hints

Hint 1

Start by pinpointing the exact error message. `Connection timed out`, `Connection refused`, and `Connection reset by peer` each point to a different layer — nail that down before touching the host.

Hint 2

A `tcpdump` on the host itself (accessed via console) is the single most decisive check in the whole procedure: if no SYN arrives, the problem is upstream; if a SYN arrives and a RST leaves, the host is rejecting it locally.

Hint 3

Don't forget the gap between 'sshd is running' and 'sshd can handle new connections' — fd exhaustion, listen-backlog overflow, a misconfigured `ListenAddress`, and a hung process in D-state can all make a running daemon effectively unreachable.