Why does ssh frequently disconnect with 'connection reset by peer'?

EDIT: The router turned out to be the problem. After switching the router (DIR-655) for a DSR-250N I've had 100% uptime for a week now which is unheard of for my internet in the past few years. So, I'm marking this as the answer. Sometimes it helps to just swap in a different router, I guess.

Update 2018-04-20: Router has been very stable since July 2017 when I replaced it. Not perfect but, for example, my ssh sessions staying up for one or two weeks at a time, whereas before they were crashing within an hour frequently. I suspect some of my disconnects are even due to the ISP rather than the router.

It's a little early to tell but, after having actual internet outages more frequently than I would expect, I swapped out my DIR-655 for a DSR-250N (due to good experience at our office with this router) and it hasn't exhibited any of the previous symptoms either with internet outages or ssh disconnecting.

I'll give it a week and if ssh stays up for longist periods at a time I'll call this the answer.

Who knew? It could just be a bad / deteriorating router...


Edit: This worked for longer than I expected but also quit sooner than configured for. I have a ping server watching my internet connection and it doesn't look like any internet connectivity issues came up. So can't say this is the fix.

After trying countless combinations of client-side and server-side variations of TCPKeepAlive, ServerAliveInterval, ServerAliveCountMax, ClientAliveInterval, and ClientAliveCountMax, I synchronized both client and server to these settings:

Client:

TCPKeepAlive no

ServerAliveInterval 60

ServerAliveCountMax 525600

Server:

TCPKeepAlive no

ClientAliveInterval 60

ClientAliveCountMax 525600

And I've been running all day (crosses fingers) during which I would have fully expected to have been disconnected frequently and quickly.

Note my AliveCountMax values are questionably large, you should tweak to suit your needs.