Starlink SSH broken pipe and firewall blocking
user: We are using Starlink Internet I keep getting a broken pipe early in an SSH terminal session with my server. Is this a known issue with starlink. Does it have something to do with the MTU size or anything like that? Also it seems my firewall logs indicate alot of blocking on this network, is that also a known issue of startlink networks under heavy attack?
assistant: Yeah — **SSH “broken pipe” on Starlink is a pretty common symptom of Starlink’s link behavior**, and it’s *usually not MTU*.
## Why it happens on Starlink (the real reason)
Starlink can have **micro-loss + jitter spikes**, especially around **regular satellite handovers**. Geoff Huston’s measurements show latency shifting on a ~15-second cadence (satellite assignment changes), with **loss events at switchover** and additional loss from obstruction/signal quality/congestion. That kind of short disruption is enough to make an interactive TCP session like SSH look “dead” and get torn down.
Also, even small obstructions can cause brief interruptions; Starlink explicitly calls out that the app’s obstruction map shows blockages and how they affect experience.
## Is it MTU?
**Usually no** for plain SSH. MTU issues tend to show up as **connections that “half work”** (connects, but hangs when sending/receiving larger packets), especially when a **VPN** is involved.
That said, you can *prove it* quickly from your Starlink-side machine:
```bash
# Shows discovered path MTU; if you see something weird like 1420/1460 etc, note it.
tracepath -n YOUR_SERVER_IP
# IPv4 DF ping test for 1500-byte MTU path (1472 payload + 28 headers = 1500)
ping -M do -s 1472 -c 3 YOUR_SERVER_IP
# If that fails, step down (1464, 1452, 1440...) until it succeeds.
# If you use IPv6 to the server:
ping -6 -M do -s 1452 -c 3 YOUR_SERVER_IPV6
```
If you’re **also running WireGuard/OpenVPN/etc**, then MTU becomes much more likely (because tunnel overhead shrinks usable MTU). But for direct SSH, Starlink’s jitter/micro-outages are the usual culprit.
## The fix that helps most: SSH keepalives (client + server)
This doesn’t “fix Starlink,” but it **keeps NAT state warm** and makes SSH detect a hiccup faster/recover more gracefully.
### On your Starlink client (recommended)
Add to `~/.ssh/config`:
```sshconfig
Host yourserver
HostName your.server.name.or.ip
ServerAliveInterval 10
ServerAliveCoun…
user: make a really cool looking infographic about this for my blog
user: adam@laptop:~$ # Shows discovered path MTU; if you see something weird like 1420/1460 etc, note it.
tracepath -n 178.156.185.220
bash: tracepath: command not found
adam@laptop:~$ # IPv4 DF ping test for 1500-byte MTU path (1472 payload + 28 headers = 1500)
ping -M do -s 1472 -c 3 178.156.185.220
# If that fails, step down (1464, 1452, 1440...) until it succeeds.
PING 178.156.185.220 (178.156.185.220) 1472(1500) bytes of data.
1480 bytes from 178.156.185.220: icmp_seq=1 ttl=44 time=94.0 ms
1480 bytes from 178.156.185.220: icmp_seq=2 ttl=44 time=101 ms
1480 bytes from 178.156.185.220: icmp_seq=3 ttl=44 time=153 ms
--- 178.156.185.220 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 93.977/115.826/152.832/26.309 ms
adam@laptop:~$ # If you use IPv6 to the server:
ping -6 -M do -s 1452 -c 3 2a01:4ff:f0:cf9f::1
ping: connect: Network is unreachable
assistant: Nice — those results basically rule out MTU (for IPv4).
## What your tests say
### ✅ IPv4 MTU is fine
Your DF ping with `-s 1472` (1500-byte path) succeeded 3/3 with 0% loss:
- That means your path supports **at least MTU 1500** end-to-end (no fragmentation needed).
- So your **SSH “broken pipe” is almost certainly NOT an MTU issue** (at least on IPv4, non-VPN).
If this were MTU/PMTUD trouble, that DF ping would usually fail or you’d see weird “works until it doesn’t” behavior with larger packets.
### ❌ IPv6: your client currently has no IPv6 connectivity
`ping -6 …` → `Network is unreachable` means your laptop has **no IPv6 route**. That’s not a server problem — that’s local network/ISP side.
Run these on the laptop to confirm what you actually have:
```bash
ip -6 addr
ip -6 route
```
- If you only see `fe80::` addresses and no `2000::/3` global address + default route, you’re not on IPv6 right now.
- Starlink *can* provide IPv6 in many setups, but it’s not guaranteed everywhere and can depend on router mode/config. Either way: your current laptop network path is **IPv4-only**.
## So why the SSH “broken pipe” still happens?
With Starlink, the usual culprit is **brief micro-outages / jitter spikes** (sat handoffs, obstruction blips, transient congestion). SSH is TCP; if the link stalls long enough, the session can get dropped and you see “broken pipe”.
## Do this (it fixes 90% of Starlink SSH pain)
### 1) Add SSH keepalives on your laptop
`~/.ssh/config`:
```sshconfig
Host yourserver
HostName 178.156.185.220
ServerAliveInterval 10
ServerAliveCountMax 3
TCPKeepAlive yes
```
Or one-off:
```bash
ssh -o ServerAliveInterval=10 -o ServerAliveCountMax=3 youruser@178.156.185.220
```
### 2) (Optional) Add server-side keepalives
On server: `/etc/ssh/sshd_config`
```sshconfig
ClientAliveInterval 30
ClientAliveCountMax 3
```
Then:
```bash
sudo systemctl restart ssh
```
### 3) Use MOSH if you want it to feel “unbreakable”
MOSH is made for flaky/roaming…
user: I'm using UFW on my Debian 13 laptop. give me the command to audit the log
assistant: Use these (they’re safe read-only) on your Debian 13 laptop:
```bash
# 1) Confirm logging is on + show UFW status/rules
sudo ufw status verbose
# 2) Where UFW is writing logs (usually /var/log/ufw.log via rsyslog/journald)
sudo ls -lah /var/log/ufw.log*
# 3) Live tail of UFW blocks/denies (most useful)
sudo tail -f /var/log/ufw.log | grep -E "UFW BLOCK|UFW DENY|DPT=|SRC="
```
If `/var/log/ufw.log` doesn’t exist on your system, audit via journal instead:
```bash
# UFW-related kernel log events (live)
sudo journalctl -k -f | grep -E "UFW BLOCK|UFW DENY"
# Or last 24 hours
sudo journalctl -k --since "24 hours ago" | grep -E "UFW BLOCK|UFW DENY"
```
If you want a quick “top offenders / top ports” summary from the log:
```bash
sudo awk '/UFW (BLOCK|DENY)/{
for(i=1;i<=NF;i++){
if($i ~ /^SRC=/){sub("SRC=","",$i); src=$i}
if($i ~ /^DPT=/){sub("DPT=","",$i); dpt=$i}
}
if(src!="") SRC[src]++
if(dpt!="") DPT[dpt]++
}
END{
print "Top source IPs:"; for (s in SRC) print SRC[s], s | "sort -nr | head -n 20"
print "\nTop destination ports:"; for (p in DPT) print DPT[p], p | "sort -nr | head -n 20"
}' /var/log/ufw.log
```
user: I didn't run your 24 hour command because it would have been too long for this post, but I'll take a look later, out of curiosity.
adam@laptop:~$ # 1) Confirm logging is on + show UFW status/rules
sudo ufw status verbose
[sudo] password for adam:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
adam@laptop:~$ # 2) Where UFW is writing logs (usually /var/log/ufw.log via rsyslog/journald)
sudo ls -lah /var/log/ufw.log*
ls: cannot access '/var/log/ufw.log*': No such file or directory
adam@laptop:~$ # 3) Live tail of UFW blocks/denies (most useful)
sudo tail -f /var/log/ufw.log | grep -E "UFW BLOCK|UFW DENY|DPT=|SRC="
tail: cannot open '/var/log/ufw.log' for reading: No such file or directory
tail: no files remaining
adam@laptop:~$ # UFW-related kernel log events (live)
sudo journalctl -k -f | grep -E "UFW BLOCK|UFW DENY"
Feb 15 22:27:44 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:1c:6a:1b:95:1c:27:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:27:45 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:fb:d0:12:55:30:7b:31:08:00 SRC=192.168.1.33 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:27:48 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:fb:e4:38:83:91:b3:ab:08:00 SRC=192.168.1.1 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:28:20 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:fb:1a:a8:4e:a5:56:0f:08:00 SRC=192.168.1.112 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=8319 PROTO=2
Feb 15 22:29:52 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:1c:6a:1b:95:1c:27:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:29:53 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:fb:78:55:36:05:20:1a:08:00 SRC=192.168.1.37 DST=224.0.0.251 LEN=32 TOS=0x00 PREC=0x00 TTL=1 ID=62461 PROTO=2
F…
assistant: What you’re seeing there **isn’t “Starlink under attack.”** Those log lines are **local Wi-Fi LAN multicast noise** (mDNS + IGMP):
- `DST=224.0.0.251` = **mDNS / Bonjour** (UDP 5353) from devices on your LAN (`192.168.1.x`)
- `DST=224.0.0.1` with `PROTO=2` = **IGMP** membership chatter
- `TTL=1` = **never leaves your local network**
Also, your Debian 13 laptop simply isn’t writing UFW logs to `/var/log/ufw.log` (common when you’re using **journald** without rsyslog file outputs), so the “audit the log” needs to use **journalctl**.
## Audit UFW blocks in the journal (clean + useful)
### Show last 1 hour (quick sanity check)
```bash
sudo journalctl -k --since "1 hour ago" -g "UFW (BLOCK|DENY)" --no-pager
```
### Show last 24 hours (your original ask, but pageless)
```bash
sudo journalctl -k --since "24 hours ago" -g "UFW (BLOCK|DENY)" --no-pager
```
### Live view
```bash
sudo journalctl -k -f -g "UFW (BLOCK|DENY)"
```
## “Real audit” summary: top sources + top destination ports
(Works even though you don’t have `/var/log/ufw.log`)
```bash
sudo journalctl -k --since "24 hours ago" -g "UFW (BLOCK|DENY)" --no-pager |
awk '{
src=""; dpt="";
for(i=1;i<=NF;i++){
if($i ~ /^SRC=/){src=substr($i,5)}
if($i ~ /^DPT=/){dpt=substr($i,5)}
}
if(src!="") SRC[src]++
if(dpt!="") DPT[dpt]++
}
END{
print "Top source IPs:";
for(s in SRC) print SRC[s], s | "sort -nr | head -n 20";
print "\nTop destination ports:";
for(p in DPT) print DPT[p], p | "sort -nr | head -n 20";
}'
```
## If you only care about *non-local* / internet-looking sources
This filters out the LAN chatter (`192.168.x.x`, `10.x.x.x`, `172.16-31.x.x`) and the multicast destinations:
```bash
sudo journalctl -k --since "24 hours ago" -g "UFW (BLOCK|DENY)" --no-pager |
grep -vE 'SRC=192\.168\.|SRC=10\.|SRC=172\.(1[6-9]|2[0-9]|3[0-1])\.|DST=224\.'
```
If you run that last filter and you *still* see tons of public IPs getting blocked, paste ~10 lines (you can redact IPs), and I’ll tell you if…
user: adam@laptop:~$ sudo journalctl -k --since "1 hour ago" -g "UFW (BLOCK|DENY)" --no-pager
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC= SRC=192.168.1.216 DST=239.255.255.250 LEN=635 TOS=0x00 PREC=0x00 TTL=1 ID=8191 DF PROTO=UDP SPT=32996 DPT=3702 LEN=615
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC= SRC=fe80:0000:0000:0000:5cd2:aadb:2a3d:fd79 DST=ff02:0000:0000:0000:0000:0000:0000:000c LEN=655 TC=0 HOPLIMIT=1 FLOWLBL=285815 PROTO=UDP SPT=38069 DPT=3702 LEN=615
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:1c:6a:1b:95:1c:27:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=24:ee:9a:81:75:13:50:03:cf:77:21:a9:08:00 SRC=192.168.1.36 DST=192.168.1.216 LEN=1364 TOS=0x00 PREC=0x00 TTL=64 ID=27570 PROTO=UDP SPT=3702 DPT=32996 LEN=1344
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=24:ee:9a:81:75:13:28:c5:c8:f6:72:1a:08:00 SRC=192.168.1.103 DST=192.168.1.216 LEN=2581 TOS=0x00 PREC=0x00 TTL=64 ID=23991 PROTO=UDP SPT=3702 DPT=32996 LEN=2561
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=24:ee:9a:81:75:13:28:c5:c8:f6:72:1a:08:00 SRC=192.168.1.103 DST=192.168.1.216 LEN=2581 TOS=0x00 PREC=0x00 TTL=64 ID=23999 PROTO=UDP SPT=3702 DPT=32996 LEN=2561
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=24:ee:9a:81:75:13:50:03:cf:77:21:a9:08:00 SRC=192.168.1.36 DST=192.168.1.216 LEN=1364 TOS=0x00 PREC=0x00 TTL=64 ID=64606 PROTO=UDP SPT=3702 DPT=32996 LEN=1344
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=24:ee:9a:81:75:13:28:c5:c8:f6:72:1a:08:00 SRC=192.168.1.103 DST=192.168.1.216 LEN=2581 TOS=0x00 PREC=0x00 TTL=64 ID=24005 PROTO=UDP SPT=3702 DPT=32996 LEN=2561
Feb 15 22:00:02 laptop kernel: [UFW BLOCK] IN=wlp2s0 OUT= MAC=01:00:5e:00:00:01:1c:6a:1b:95:1c:27:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=32 TOS=0x00 PREC=0xC0 TTL=1 ID=0 DF PROTO=2
Feb 15 22:00:02 laptop kernel:…
assistant: Yep — this output is **exactly the “LAN discovery chatter”** I was talking about. Nothing here looks like an internet attack.
### What these lines actually are
You’ve got **three main buckets**:
1) **WSD / WS-Discovery** (Windows/printer discovery)
- `DST=239.255.255.250` and `DPT=3702` (IPv4 multicast)
- `DST=ff02::c` and `DPT=3702` (IPv6 multicast)
That’s normal “who’s on the network / who has services?” traffic.
2) **mDNS / Bonjour**
- `DST=224.0.0.251` (multicast)
Also normal LAN discovery.
3) **IGMP**
- `DST=224.0.0.1` with `PROTO=2` and `TTL=1`
That’s multicast group membership housekeeping.
Also notice: **everything is private LAN (`192.168.1.x`) or IPv6 link-local (`fe80::`) and TTL/HOPLIMIT is 1**, meaning it’s not going anywhere beyond the local network.
---
## Why your awk “Top source IPs” came out blank / scrambled
Because you’re piping to `sort|head` **inside the loop** without closing the pipe, the sort output flushes later and ends up printing under the wrong header.
Use this fixed version (closes the pipe properly):
```bash
sudo journalctl -k --since "24 hours ago" -g "UFW (BLOCK|DENY)" --no-pager |
awk '
{
src=""; dpt="";
for(i=1;i<=NF;i++){
if($i ~ /^SRC=/){src=substr($i,5)}
if($i ~ /^DPT=/){dpt=substr($i,5)}
}
if(src!="") SRC[src]++
if(dpt!="") DPT[dpt]++
}
END{
cmd="sort -nr | head -n 20"
print "Top source IPs:";
for(s in SRC) print SRC[s], s | cmd
close(cmd)
print ""
print "Top destination ports:";
for(p in DPT) print DPT[p], p | cmd
close(cmd)
}'
```
(You’ll see `3702` show up clearly, plus some ephemeral ports like `32996` which are just reply ports.)
---
## If you want to see **only “real” suspicious stuff** (public internet hits)
Right now, your log shows **none**. This filter will drop LAN + link-local IPv6:
```bash
sudo journalctl -k --since "24 hours ago" -g "UFW (BLOCK|DENY)" --no-pager |
awk '{
src=""
for(i=1;i<=NF;i++) if($i ~ /^SRC=/) {src=substr($i,5)}
if(src=="") next
if(src ~…
user: Thank you for the information. I think some users will find this useful on our blog post. Let's conclude this conversation and work on other things.
assistant: Sounds good, Captain. ✅
Quick takeaway for the post: what you’re seeing is **normal LAN discovery/multicast traffic** (mDNS/WSD/IGMP) getting logged by UFW — not an internet attack.
Whenever you’re ready, tell me what you want to work on next.
user: TCPKeepAlive yes
I noticed this commented out in the server SSH config, does that kinda do the same thing as the the two keep alive commands you recommended?
assistant: It’s related, but it’s **not the same thing**, and it usually **doesn’t solve the Starlink/NAT-idle “broken pipe” problem by itself**.
### What `TCPKeepAlive yes` actually does
- This enables **TCP keepalive probes at the kernel level** (SO_KEEPALIVE).
- They’re meant to detect a **dead peer** (e.g., link died) eventually.
- The catch: on Linux the default timers are **very long** (often ~2 hours before the first probe, then spaced out). So it may **not fire soon enough** to keep an idle SSH session alive through NAT, CGNAT, Wi-Fi sleep, or Starlink path changes.
### What the two keepalive settings I recommended do
There are *two* different “keepalive” families, and both are more useful for your case because they can be made **frequent**:
#### 1) Server-side (in `sshd_config`)
- `ClientAliveInterval` / `ClientAliveCountMax`
- This makes **sshd send an application-level keepalive** to the client every N seconds.
- Great for keeping state alive through NAT and for detecting stuck sessions.
Example:
```sshconfig
ClientAliveInterval 30
ClientAliveCountMax 3
```
(That’s “ping every 30s; drop after ~90s of no response.”)
#### 2) Client-side (in your `ssh_config` or command line)
- `ServerAliveInterval` / `ServerAliveCountMax`
- This makes the **client send an SSH-level keepalive** to the server.
Example:
```sshconfig
ServerAliveInterval 30
ServerAliveCountMax 3
```
### So should you enable `TCPKeepAlive`?
Usually you can just leave it at the default (`yes`). It **doesn’t hurt**, but it’s not the tool that reliably prevents early idle disconnects on flaky/CGNAT-ish networks.
**Best practical combo for your situation:**
- On the **server**: set `ClientAliveInterval 30` and `ClientAliveCountMax 3`
- On the **client**: set `ServerAliveInterval 30` and `ServerAliveCountMax 3`
- Leave `TCPKeepAlive yes` as-is.
If you tell me whether your “broken pipe” happens mostly **when idle** vs **while actively typing/streaming output**, I’ll point you to the next most likely caus…
user: Ok, I added the two lines in the SSH config
adam@mcwai:~$ sudo systemctl restart ssh
Job for ssh.service failed because the control process exited with error code.
See "systemctl status ssh.service" and "journalctl -xeu ssh.service" for details.
assistant: Good catch **and don’t log out of your current SSH session** while we fix this. When `ssh.service` won’t restart right after editing config, it’s almost always a **syntax error** or an **invalid directive** in `/etc/ssh/sshd_config`.
### 1) Get the exact error (this usually tells you the line number)
Run:
```bash
sudo sshd -t
```
If it prints something like:
- `Bad configuration option: ServerAliveInterval`
- `Unsupported option ...`
- `line XX: ...`
…that’s the smoking gun.
Then also grab the service logs (more context):
```bash
sudo systemctl status ssh.service --no-pager -l
sudo journalctl -xeu ssh.service --no-pager | tail -n 80
```
### 2) Most common cause (and the fast fix)
If you accidentally put **client-side** options (like `ServerAliveInterval`) into **sshd_config**, sshd will refuse to start.
**Server-side file**: `/etc/ssh/sshd_config` should use:
```text
ClientAliveInterval 30
ClientAliveCountMax 3
```
**Client-side file**: `~/.ssh/config` (or `/etc/ssh/ssh_config`) uses:
```text
ServerAliveInterval 30
ServerAliveCountMax 3
```
### 3) Show me the lines you added (with line numbers)
This prints only keepalive-related lines + line numbers:
```bash
sudo grep -nE 'Alive|KeepAlive' /etc/ssh/sshd_config
```
If you want to see the exact surrounding area with line numbers:
```bash
sudo nl -ba /etc/ssh/sshd_config | sed -n '1,200p'
```
### 4) Quick “get SSH back up” revert method
If you just want to restore service immediately, comment out the two lines you added, then test + restart:
```bash
sudo sshd -t && sudo systemctl restart ssh
```
(After you comment them out.)
---
If you paste the output of **`sudo sshd -t`** (just that one line/error), I can tell you *exactly* what to change in one shot.
user: actually I sent the interval at 33, but I wouldn't think that would cause an issue
adam@mcwai:~$ sudo sshd -t
/etc/ssh/sshd_config: line 14: Bad configuration option: ServerAliveInterval
/etc/ssh/sshd_config: line 15: Bad configuration option: ServerAliveCountMax
/etc/ssh/sshd_config: terminating, 2 bad configuration options
adam@mcwai:~$ sudo systemctl status ssh.service --no-pager -l
sudo journalctl -xeu ssh.service --no-pager | tail -n 80
× ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/usr/lib/systemd/system/ssh.service; disabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2026-02-16 01:09:09 EST; 1min 38s ago
Duration: 1w 10h 11min 9.130s
TriggeredBy: × ssh.socket
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1327306 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255/EXCEPTION)
CPU: 4ms
Feb 16 01:09:09 mcwai systemd[1]: ssh.service: Scheduled restart job, restart counter is at 5.
Feb 16 01:09:09 mcwai systemd[1]: ssh.service: Start request repeated too quickly.
Feb 16 01:09:09 mcwai systemd[1]: ssh.service: Failed with result 'exit-code'.
Feb 16 01:09:09 mcwai systemd[1]: Failed to start ssh.service - OpenBSD Secure Shell server.
░░
░░ An ExecStartPre= process belonging to unit ssh.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 255.
Feb 16 01:09:09 mcwai systemd[1]: ssh.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit ssh.service has entered the 'failed' state with result 'exit-code'.
Feb 16 01:09:09 mcwai systemd[1]: Failed to start ssh.service - OpenBSD Secure Shell server.
░░ Subject: A start job for unit ssh.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit ssh.service has finished with a failure.
░░
░░ The job identifier is 118396 and the job result is failed.
Feb 16 01:09:09 mcwa…
assistant: Yep — **the interval value (33) is fine**. The problem is simpler:
### What happened
You put **client-side keepalive options** into the **server** config.
- `ServerAliveInterval` and `ServerAliveCountMax` **belong in the SSH client config** (`ssh_config` / `~/.ssh/config`)
- The SSH *server* (`sshd`) uses **ClientAliveInterval** and **ClientAliveCountMax**
That’s why `sshd -t` is failing and `ssh.service` won’t start.
---
## Fix it right now (safe + exact)
### 1) Edit the server config and replace those two lines
```bash
sudo nano /etc/ssh/sshd_config
```
Go to **line 14 and 15** and change:
```text
ServerAliveInterval 33
ServerAliveCountMax 3
```
to:
```text
ClientAliveInterval 33
ClientAliveCountMax 3
```
Save and exit.
### 2) Test config (must be clean)
```bash
sudo sshd -t
```
If this prints nothing, you’re good.
### 3) Restart SSH
```bash
sudo systemctl restart ssh
sudo systemctl status ssh --no-pager -l
```
---
## About `TCPKeepAlive yes`
Not the same thing.
- **`TCPKeepAlive`** = kernel-level TCP keepalive probes (slow by default; mainly detects dead peers eventually)
- **`ClientAliveInterval/CountMax`** = **sshd application-level** keepalives (more reliable for NAT/timeouts, and you control timing)
So keep `TCPKeepAlive yes` if you want, but the two you meant to add on the server are:
```text
ClientAliveInterval 33
ClientAliveCountMax 3
```
---
## If you also want the *client-side* version (optional)
On your laptop (`adam@laptop`), you can add this to `~/.ssh/config`:
```text
Host mcwai
ServerAliveInterval 33
ServerAliveCountMax 3
```
That keeps the *client* sending probes too.
---
If you paste your first ~25 lines of `/etc/ssh/sshd_config` (with line numbers), I’ll sanity-check there aren’t any other landmines—but the error you posted is 100% explained by those two directives.
user: oh ok, I changed it to Client, but I see this
adam@mcwai:~$ sudo sshd -t
Missing privilege separation directory: /run/sshd
assistant: Good catch — that message means **sshd can’t find `/run/sshd`**, which it uses at runtime for privilege separation. It’s usually created automatically by systemd, but since sshd is failing early (and `/run` is tmpfs), it may not exist right now.
Do this:
### 1) Create it (owned by root, safe perms)
```bash
sudo mkdir -p /run/sshd
sudo chmod 0755 /run/sshd
sudo chown root:root /run/sshd
```
### 2) Re-test config
```bash
sudo sshd -t
```
### 3) Start/restart ssh
```bash
sudo systemctl restart ssh
sudo systemctl status ssh --no-pager -l
```
---
## If it comes back after reboot (make it persistent via systemd tmpfiles)
On Ubuntu/Debian, `/run` is recreated on boot, so the right long-term fix is usually tmpfiles:
```bash
printf "d /run/sshd 0755 root root -\n" | sudo tee /etc/tmpfiles.d/sshd.conf
sudo systemd-tmpfiles --create /etc/tmpfiles.d/sshd.conf
```
Then:
```bash
sudo systemctl restart ssh
```
---
If `sshd -t` still complains after that, paste the output of:
```bash
ls -ld /run /run/sshd
sudo systemctl cat ssh.service | sed -n '1,120p'
sudo journalctl -xeu ssh.service --no-pager | tail -n 80
```
user: if my laptop has this TCPKeepAlive yes then why not uncomment the same line on the server? you said to leave it as is.
Host yourserver
HostName 178.156.185.220
ServerAliveInterval 10
ServerAliveCountMax 3
TCPKeepAlive yes
assistant: Two key points:
1) **Leaving `TCPKeepAlive` commented in `sshd_config` does *not* mean it’s “off.”**
In OpenSSH, `TCPKeepAlive` defaults to **yes** on both client and server. So:
- `#TCPKeepAlive yes` (commented) ➜ **still behaves like yes**
- `TCPKeepAlive yes` (uncommented) ➜ same behavior, just explicit
- `TCPKeepAlive no` ➜ changes behavior (turns it off)
So on the server, uncommenting `TCPKeepAlive yes` usually **changes nothing**.
2) **`TCPKeepAlive` is *not* the same thing as `ServerAliveInterval/CountMax`.**
They operate at different layers:
- **`TCPKeepAlive`** = kernel-level TCP keepalives (SO_KEEPALIVE).
On Linux these are typically **very slow by default** (often ~2 hours before the first probe), and they’re mainly for detecting dead peers eventually. They do **not reliably keep NAT/firewall state alive** in the way you want for SSH sessions/tunnels.
- **`ServerAliveInterval` + `ServerAliveCountMax`** = SSH-protocol keepalives (application-layer).
These are **frequent**, encrypted “are you there?” checks that work much better for keeping NAT mappings alive and detecting broken links quickly.
That’s why I told you to use the **SSH-layer keepalives** (`ServerAlive*` on the client, and if you want the server side equivalent, use **`ClientAliveInterval` / `ClientAliveCountMax`** in `sshd_config`).
### Practical rule
- Keep your client block like you have it (good for NAT/tunnels):
```
ServerAliveInterval 10
ServerAliveCountMax 3
```
- On the server, **don’t bother uncommenting `TCPKeepAlive yes`** because it’s already effectively on by default.
- If you want server-side “active” keepalives, set:
```
ClientAliveInterval 60
ClientAliveCountMax 3
```
(Adjust if you want it more aggressive.)
So: your laptop having `TCPKeepAlive yes` doesn’t mean you *need* to explicitly set it on the server — and it’s not a replacement for the `ServerAlive*` behavior you were aiming for.
user: make an cool looking infographic for my blog about this keepalive we've been discussing
Showing first 24 of 38 messages. View the full conversation at https://mcwai.org/ai-conversation/starlink-ssh-broken-pipe-and-firewall-blocking