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

Why do I get 'connection reset by peer' ssh disconnections more frequently from my home internet versus the office internet?

I've been researching this issue on and off for years now and the other questions&answers on this site and Google don't help me.

Here's an actual disconnect example when my internet was otherwise fine:

Read from remote host examplehost.com: Connection reset by peer Connection to examplehost.com closed.

I've been through all the checking of ssh/sshd config, etc., for things like ServerAliveInterval, ServerAliveCountMax, TCPKeepAlive, including esoteric suggestions like enable/disable GSSAPIAuthentication-related settings.

All systems are CentOS servers.

I connect to the same servers, via ssh, from the office and at home. I setup the routers, myself, at both places. The office router is an small-office class DSR-250N and my home router is a home-class DLink DIR-655.

Possibly of interest: I use VPN and, intriguingly, ssh connections over VPN seem to stay up as long as the VPN stays up (days to weeks).

This has been going on for years so I now suspect it has to do with router limitations rather than who provides the internet, but I'm not sure exactly what limitations there might be on a home-class router and what to look for in a new router to ensure these problems are at least reduced significantly.

Maybe it's router memory, maybe it's something like those 'session limit' specs I see on some routers, etc.?

I would be satisfied to know if the problem is just my relatively low-end router (although I think it's upper-middle end for home routers).

Thank you,


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.