I have been seeing an strange behaviour on my SSH connection for years but never thought of raising a question until today. I tried to search a lot about this but couldn't find any reason.
- Basically, I have various AWS EC2 instances running on different regions (like Ireland, Mumbai etc.).
- I have a Mac.
- And I'm located in India (in case it strikes someone some reason).
Problem Statement 1
When my Mac is connected to a personal hotspot (from a Samsung device or from an iPhone) over 4G network, my SSH connection freezes after a few minutes (not more than 3) if I do not work on the SSH session (basically, the SSH connection went ideal). So I have to keep pressing the arrow key just to keep it alive.
Problem Statement 2 (which is not a problem)
But when my Mac is connected to a Wifi broadband connection, this problem never occurs. My SSH connection stays connected for hours even after I wake up my Mac from sleep (open the lid).
Based on my Googling again today, I found various articles which gives solution to use options like
- What options `ServerAliveInterval` and `ClientAliveInterval` in sshd_config exactly do?
- How does tcp-keepalive work in ssh?
But I couldn't find any post which dictates this problem. Does anyone of you have any idea about this behaviour? I'll be happy to provide you any possible details of my 4G hotspot connection.