My SSH sessions die at what seem like random times - response will stop, and then a few seconds later PuTTY will pop up a message with, "Server unexpectedly closed network connection." It seems to most often happen when idle, but not always - it might even die when I'm typing in vim or something (very frustrating!). But it's pretty frequent - if I'm very lucky it might survive for a few hours, but if I'm unlucky it might die within seconds or minutes of a login.
- Server: VPS with CentOS 5.6, WebMin 1.62, OpenSSH 4.3
- FTTH (or probably more accurately, to the building: 104 condos)
- router #1 running NAT and security
- router #2 running just as wireless access point
- Windows 7 laptop (but I had the same problem with an XP desktop)
- PuTTY 0.62
Most of the time I don't even use the wifi, but just connect TCP-IP (with a hub) to router #1 - but the problem remains. I assume the fundamental cause is hiccups in my ISP's connectivity (or something in the building), but I probably can't solve that, so the reason I'm asking this on ServerFault is because I'm just trying to configure SSH (or PuTTY or whatever it takes) so that it doesn't terminate the session so easily.
I have tried various things that other people have found useful:
Setting PuTTY's Connection->"Seconds between keepalives" to various non-zero values (I don't know if that setting is like TCPKeepAlive or more like ServerAliveInterval, but it's the only setting available in PuTTY)
Trying to make the server do the work, by turning PuTTY's keepalive off (0) and then on the server, including this in sshd_config:
TCPKeepAlive no ClientAliveInterval 60 ClientAliveCountMax 3000
Changing to a static IP for my PC (that was the solution for this question on SuperUser.com)
But it still dies in all variations - it's difficult to tell if one set of settings is slightly better than another, but each has failed even today in less than an hour. And this problem is quite consistent over the long term - I have put up with it for the couple years I have been managing this server (I'm mostly a programmer, so I don't spend a ton of time in SSH, but when I do need it, it's frustrating to keep losing my session). Any thoughts?