> ## Content Index
> Fetch the complete content index at: https://aquasp.blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to avoid timeouts while you are logged on SSH
- URL: https://aquasp.blog/how-to-avoid-timeouts-while-you-are-logged-on-ssh/
- Published: 2025-12-09T01:41:02.000Z
- Updated: 2025-12-09T01:41:02.000Z
- Description: Are you having issues with constant disconnections on SSH? Here is the guide for you.
- Author: Aquasp
- Tags: Guides

# Introduction

One of the most frustrating things when working on a server?

Your SSH session dies because of a brief Wi-Fi hiccup, idle timeout, or flaky connection.

**Fix it forever in 30 seconds.**

## The Universal Fix: Edit Your SSH Config

This works on **Linux, macOS, and Windows** — and survives network glitches up to \~4–5 minutes.

### Step 1: Create or Edit the SSH Config File

**On Linux / macOS:**

```bash
mkdir -p ~/.ssh
nano ~/.ssh/config
```

**On Windows (PowerShell):**

```
# Replace YourUsername with your actual Windows username
mkdir "$HOME\.ssh" -Force
notepad "$HOME\.ssh\config"
```

### Step 2: Add These Lines

```
sshHost *
    ServerAliveInterval 120
    ServerAliveCountMax 3
    TCPKeepAlive yes
```

Save and exit.

Done. That’s it.

## What This Actually Does

| Setting                 | Meaning                                                               |
| ----------------------- | --------------------------------------------------------------------- |
| Host \*                 | Apply these rules to **every** SSH connection                         |
| ServerAliveInterval 120 | Every 2 minutes, your computer sends a tiny “I’m still here” packet   |
| ServerAliveCountMax 3   | If 3 packets in a row fail → only then close the connection (\~6 min) |
| TCPKeepAlive yes        | Extra OS-level keepalive (helps with some routers/firewalls)          |

Result: Your SSH session now survives:

- Wi-Fi switching
- Laptop sleep/wake
- Brief internet drops
- VPN reconnects

…without freezing or dying.

## You're Now Unbreakable

From now on, when your internet blinks, your SSH session just… waits patiently.

No more “Connection reset by peer”  
No more lost tmux sessions  
No more rage

You’ve officially leveled up.

If this saved your sanity, share it with a fellow admin or subscribe to **The Self Hosting Art**.

Thank you for reading — stay connected!