Fix a slow SSH connection
We'll run ssh -v to find the delay, disable GSSAPI and DNS lookups, and tune connection options—or point you to network fixes.
What you'll need
- SSH access to the server
- sudo on the server (for sshd_config)
Step-by-step diagnostic
Quick triage — pick your path
Get started
Choose the option that matches what you see. You can jump straight to that section.
Show full guide
Steps
Goal: Find the delay with ssh -v, then disable GSSAPI, DNS, or tune for network.
- Run
ssh -v user@hostto see where time is spent. - Good: You see a pause before “Offering public key” (GSSAPI), at connection start (DNS), or during the session (network). Proceed to Run ssh -v first.
- Bad: Run ssh -vv for more detail.
Run ssh -v first
Goal: Identify the bottleneck.
- Run
ssh -v user@host. Watch for long pauses. - Pause before “Offering public key”: GSSAPI is trying authentication—disable it.
- Pause at connection start: reverse DNS lookup on the server (UseDNS).
- Pause during session: network latency—check ping and consider Compression.
- Good: Bottleneck identified. Proceed to Disable GSSAPI and DNS.
- Bad: Compare
time ssh user@host exitvstime ssh user@ip exit. If IP is faster, DNS adds delay.
Disable GSSAPI and DNS
Goal: Remove GSSAPI and DNS delays.
- Client: Add to
~/.ssh/config:Host * GSSAPIAuthentication no GSSAPIKeyExchange no - Server: Edit
/etc/ssh/sshd_config. Add or setUseDNS no. Runsudo systemctl restart sshd(or ssh). - For slow links: Add
Compression yesto~/.ssh/config. - Good: GSSAPI and UseDNS disabled. Reconnect and confirm faster.
- Bad: If delay persists, check network—see fix-modem-will-not-connect or fix-firewall-blocks-ssh.
Add connection reuse (optional)
Goal: Reuse a single connection for multiple sessions.
- Create
~/.ssh/sockets. Add to~/.ssh/config:Host * ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h-%p ControlPersist 600 - First login opens the connection. Subsequent logins reuse it and are instant.
- Good: Multiple sessions share one connection.
- Bad: Not applicable if the delay is on first connection only.
When to escalate
Escalate if:
- You cannot change sshd_config (managed servers).
- The delay is purely network latency (high ping).
- The fix requires firewall or modem changes.
Provide ssh -v output.
Verification
ssh user@hostreaches the prompt in under a few seconds (after GSSAPI and UseDNS disabled).- No long pause before “Offering public key”.
time ssh user@host exitshows reduced connection time.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- ssh -v Run ssh -v to identify the bottleneck.
- Disable GSSAPI GSSAPIAuthentication no, GSSAPIKeyExchange no in ~/.ssh/config.
- Disable UseDNS UseDNS no in sshd_config; restart sshd.
- Compression and ControlMaster Add compression and connection reuse.
- Escalate Network or managed server; provide ssh -v output.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- ssh -v output (especially around the delay)
- ~/.ssh/config contents
- sshd_config UseDNS and GSSAPI settings
- Steps already tried
Where does ssh -v show the delay?
Run ssh -v user@host. Watch for pauses.
You can change your answer later.
Run ssh -vv
Is the delay before key auth (GSSAPI)?
GSSAPI attempts add 5–30 seconds before falling back to keys.
You can change your answer later.
Disable GSSAPI
Is the delay from DNS or reverse DNS?
Compare ssh user@host vs ssh user@ip. If IP is faster, DNS adds delay.
You can change your answer later.
Disable UseDNS
Network latency?
Reviewed by Blackbox Atlas
Frequently asked questions
- Why is SSH slow to connect?
- GSSAPI authentication attempts, reverse DNS lookup on the server, or slow network. Run ssh -v to see where the delay occurs.
- Can I fix slow SSH myself?
- Yes. Disable GSSAPIAuthentication and GSSAPIKeyExchange on the client. Set UseDNS no on the server. Add compression for slow links.
- When should I escalate slow SSH?
- If the delay is network latency, firewall, or modem-related. Or if you cannot change sshd_config (managed servers).
Rate this guide
Was this helpful?
Thanks for your feedback.