I'm trying to figure out why open SSH connections are disconnected
Long time customer, first time caller.
I'm having trouble keeping SSH connections alive when connected to my Linode. I went through a few things with Support (described below), but those things haven't resolved the problem and I'm turning to the community for additional help.
If I reboot my Linode, I can SSH into it, again, for what seems like a limited length of time (perhaps 10 - 30 minutes or so?). Then, unexpectedly, the session ends and my console says "port 22 closed" and something about a "broken pipe".
Here's what Support and I have tried:
mtrfrom my laptop to my Linode and all was deemed well.
mtrfrom my Linode back to my laptop — same result: all was deemed well.
I added the following to my Linode's /etc/ssh/sshd_config file:
–- ClientAliveInterval 20
--- ClientAliveCountMax 5
- I added the following to my laptop's ~/.ssh/config:
--- Host *
--- TCPKeepAlive yes
--- ServerAliveInterval 120
I'm running macOS Sierra on my laptop, and this problem happens at home and at the office … so I think we can rule-out local network specific things? I'm not really good at this stuff, in general; what you see above is about as skilled as I get — any ideas what else I might try to diagnose and/or resolve this issue?
My suggestion, is to remove the sshd_config lines you added (ClientAlive*) they are not needed. What I suggest, is to lower your ServerAliveInterval in your ~/.ssh/config to something less than or equal to 30, try with an empty config file that only has this line:
Usually that is all it takes to force ssh connections to live forever, until closed by hand, if 30 isn't enough then keep lowering the value down to 15. Make sure to restart your sshd after you make the changs.