I'm trying to ssh to a remote server. But after the ssh is successful the connection freezes within 2-3 minutes and eventually drops.
On checking packet trace i observed my mac is randomly sending a RST packet to the remote server that is causing the connection to close.
If this isn't already strange enough, i found that this happens if open a file in vim after establishing the ssh connection but if i ssh and leave the terminal as it is then the connection doesn't freeze.
How can i debug this issue? How can i find why my mac is doing so?
I tried to restart the ssh service on macbook but it didn't solve the issue
If i do hard reboot of Mac then the issue is fixed
PS: I have the following parameters in my ssh_config file
Host *
ServerAliveInterval 60
ServerAliveCountMax 30
This issue started after there was a network issue and all my ssh connections were abruptly dropped. After that when i'm trying to ssh i observer this behaviour
-
1Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Community– Community Bot2025年07月08日 14:17:16 +00:00Commented Jul 8 at 14:17
-
Try lowering the ServerAliveInterval, maybe to 20-30 seconds. Also, enable TCPKeepAlive (which is enabled by default, but you never know...). If you have control over the server, you can also enable ClientAliveInterval/-Max on the server side. I had similar issues when using SSH over a mobile network connection (phone hotspot). Looks like mobile providers have a very low keepalive setting and terminate the connection forcibly as soon as nothing goes there for a few seconds.Mike– Mike2025年07月08日 16:21:24 +00:00Commented Jul 8 at 16:21