What Causes Broken Pipe
Your SSH connection drops due to:
- Network interruption
- Firewall killing idle connections
- NAT timeout on your router
- Server-side timeout
- Local computer going to sleep
Fix 1: Keep SSH Connection Alive (Client Side)
Add to ~/.ssh/config:
Host *
ServerAliveInterval 60
ServerAliveCountMax 10Or command line:
ssh -o ServerAliveInterval=60 hxroot@YOUR_IPFix 2: Server Side Keep-Alive
Edit /etc/ssh/sshd_config:
ClientAliveInterval 60
ClientAliveCountMax 10Restart SSH:
sudo systemctl restart sshdFix 3: Use Screen or Tmux
Run long processes inside a session that survives disconnection:
# Install screen
sudo apt install screen -y
# Start a screen session
screen -S mysession
# Detach: Ctrl+A, then D
# Reattach: screen -r mysessionFix 4: Disable SSH Compression
Compression can cause issues on unreliable networks:
ssh -o Compression=no hxroot@YOUR_IPFix 5: Check MTU Size
Packet fragmentation can cause disconnects. Test lower MTU:
ping -M do -s 1400 YOUR_IPIf failing, reduce MTU in SSH config:
ssh -o IPQoS=throughput hxroot@YOUR_IP