惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
G
Google Developers Blog
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
爱范儿
爱范儿
B
Blog
云风的 BLOG
云风的 BLOG
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
博客园 - 叶小钗
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
博客园_首页
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
SSH Sessions Dropping Frequently? Here's Exactly How I Tr...
Sreekanth Kuruba · 2026-06-20 · via DEV Community

Sreekanth Kuruba

Ever had your SSH session disconnect right in the middle of a production deployment?

I have.

After getting burned by it a few times, I created a simple troubleshooting checklist that helps me quickly find the root cause.


You're in the middle of a critical deployment or debugging session on a production server.

Suddenly:

Connection to 172.20.10.5 closed by remote host.

You reconnect… and it happens again 5 minutes later.

If this sounds familiar, you're not alone. SSH disconnections are one of the most frustrating issues for developers and DevOps engineers.

Here's the exact checklist I use to diagnose and fix recurring SSH disconnect problems.


1. Check Network Connectivity First

ping <server-ip>
traceroute <server-ip>
mtr <server-ip>          # Great for intermittent network issues

Look for:

  • Packet loss
  • High latency
  • Unstable VPN connections
  • ISP connectivity issues

Sometimes the problem isn't the server at all.


2. Check Server Resource Usage

Overloaded servers often become unresponsive and can drop SSH sessions.

top
htop
free -h
uptime

Pay special attention to:

  • High load average
  • Very low available memory
  • OOM (Out Of Memory) Killer activity
  • CPU saturation

3. Check SSH Logs

SSH logs often tell you exactly why the connection was terminated.

Ubuntu/Debian

sudo tail -f /var/log/auth.log

RHEL/CentOS/Rocky

sudo tail -f /var/log/secure

Modern systems

sudo journalctl -u sshd -f

Look for:

  • Timeout messages
  • Authentication failures
  • SSH daemon restarts
  • Connection errors

4. Fix SSH Timeout Settings (Server Side)

Edit the SSH daemon configuration:

sudo nano /etc/ssh/sshd_config

Add or modify:

ClientAliveInterval 300
ClientAliveCountMax 3

This means:

  • Send a keepalive packet every 300 seconds.
  • Disconnect only after 3 failed responses.

Restart SSH:

sudo systemctl restart sshd


5. Configure Client-Side Keepalive

Create or edit:

nano ~/.ssh/config

Add:

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3

This helps prevent many idle SSH disconnections.


6. Check Firewalls, VPNs & Load Balancers

Some common culprits:

  • Firewall idle timeouts
  • Cloud load balancer timeouts
  • VPN session timeouts
  • NAT session expiration

Always troubleshoot the entire network path, not just the server.


7. Use tmux or screen (A Life Saver)

tmux
# Do your work
Ctrl + B then D   # Detach
tmux attach       # Reconnect later

This is a must-have habit for anyone working on Linux servers.

Even if your SSH session disconnects, your processes keep running.


8. Check System Limits

ulimit -a
cat /etc/security/limits.conf

Low limits can sometimes cause unexpected connection issues under heavy load.


Bonus Tip: Enable SSH Debugging

If the issue is difficult to reproduce:

ssh -vvv user@server-ip

The verbose output often reveals:

  • Authentication issues
  • Timeout problems
  • Network interruptions
  • Key exchange failures

A Real Production Incident

During a late-night deployment, our SSH sessions kept disconnecting every 3–4 minutes.

We initially suspected the server itself. CPU and memory looked fine, and SSH logs showed nothing unusual.

The actual culprit?

A firewall between our workstation and the server had an aggressive idle timeout configured.

Increasing the timeout and enabling SSH keepalives fixed the issue completely.

That incident taught me an important lesson:

Don't just troubleshoot the server. Troubleshoot the entire path between your machine and the server.


My SSH Troubleshooting Flow

SSH Keeps Disconnecting
        ↓
1. Network (ping/mtr)
        ↓
2. Server Resources (top/free)
        ↓
3. SSH Logs
        ↓
4. Timeout Settings (Server + Client)
        ↓
5. Firewall / LB / VPN
        ↓
6. Use tmux (always)


Final Thoughts

Most SSH disconnections usually come down to:

  • Idle timeout settings
  • Unstable network connections
  • Resource exhaustion
  • Firewall or VPN timeouts
  • Missing keepalive configuration

One final tip: I never perform deployments directly in a normal SSH session anymore.

Everything runs inside tmux.

Even if my connection drops, my work keeps running.


Have you ever faced a strange SSH disconnect issue? I'd love to hear your experience in the comments.