Okay. So this was driving me absolutely nuts!!! I am a network admin and I purchased a new MacBook and I couldn't keep an SSH session alive for more than like 10 seconds without getting a broken pipe to any of about a thousand devices I have access to.
I have tried a million things and I FINALLY fixed this. I hope this helps everyone else out there with this problem that couldn't find a solution. I changed my client side (MacOS X) SSH keepalive to an insanely high number. Seems to have done the trick. It also seems to have fixed connectivity problems between other protocols as weel, such as RDP. I do not use RDP as frequently but I was having connectivity problems there as well that seem to have been rectified.
I hope this helps!
sudo sysctl -w net.inet.tcp.always_keepalive=xx
In my case, sudo sysctl -w net.inet.tcp.always_keepalive=9999