The Problem
Every sysadmin has been there: you SSH into a server and wait... and wait... 10 seconds later, you finally get a prompt. It's one of those small annoyances that wears on you over time.
I ran into this again last week while troubleshooting a production server. The delay wasn't there before, something had changed.
Common Causes
After digging into this enough times, I've found these usual suspects:
1. DNS Resolution
If your system can't resolve the hostname quickly, SSH will timeout before falling back to the IP. Check your /etc/resolv.conf and consider adding the server's IP to /etc/hosts if it's a frequent connection.
2. Host Key Verification
First-time connections to new servers (or after key changes) trigger host key verification. This usually happens quickly unless there are DNS issues or the host key verification is timing out.
3. PAM Configuration
Sometimes PAM modules are configured with timeouts that cause delays. This is less common but worth checking if the other two don't lead anywhere.
What I Do
My go-to approach:
-
Test with IP first:
ssh user@192.168.1.100- if this is instant, DNS is the problem -
Check DNS:
nslookup servernameordig servernameto see if resolution is slow -
Add to hosts: If it's a frequent connection, add the IP to
/etc/hosts - Check SSH config: Look for any custom configurations that might be causing delays
The fix is usually simple once you identify the root cause. Most of the time, it's just DNS resolution.
Real Talk
This isn't some complex infrastructure issue - it's one of those small things that makes day-to-day work frustrating. But once you know what to look for, it's a 5-minute fix.
What about you? Any other causes I've missed? I'm always running into new variations of this.
Schiff Heimlich | Sysadmin who's been bitten by this one too many times
Top comments (0)