How to determine reason for SSH broken pipe

sshwifi

Over the last week, my SSH connection to an Amazon EC2 instance keeps getting disconnected with

Write failed: Broken pipe

Reading through a few sites, I assumed it was due to no timeouts being set so I created a ~/.ssh/config file as follows based on

### Stop timing out connections
ServerAliveInterval 120  
ServerAliveCountMax 20  

TCPKeepAlive yes

### SSH Connection pooling for faster additional connections to a machine
ControlMaster auto  
ControlPath /tmp/ssh_mux_%h_%p_%r

Host *  
  ControlMaster auto  
  ControlPath ~/.ssh/control/%r@%h:%p  
  ControlPersist 3600  

### Make it so ssh-ing from one server to another passes keys around automagically
Host *
ForwardAgent yes

### Get rid of SSH connection delays
GSSAPIAuthentication no

### Use less encryption on servers I cant get to off-network
Host 10.* 172.* 192.168.*  
Ciphers blowfish-cbc

These settings didn't seem to have an effect, yet I realized that when I'm not at home, the connection stays idle like it has for the last year. I've ssh'ed into the instance on two separate networks other than my home Wifi, so I'm guessing there is something that happened at home in the last two week to change how the SSH connection behaves.

Using Wireshark or otherwise how can I follow/diagnose what/where the problem for broken SSH pipes occurs on my home network?

Using

  • Mac OS 10.7.5
  • OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
  • Amazon EC2 AMI t1.micro

Best Answer

Check for local keep alive settings on your mac. These were mine...:

sysctl -a | grep tcp.keep
net.inet.tcp.keepidle: 3600
net.inet.tcp.keepintvl: 150
net.inet.tcp.keepinit: 75000
net.inet.tcp.keepcnt: 8

I needed to change the keepintvl setting to some higher value:

sudo sysctl -w net.inet.tcp.keepintvl=7500

Then the ssh "write failed: Broken pipe" error messages vanished.