Comment by bloak

1 month ago

From what I've read, TCPKeepAlive can be a good or a bad thing. On the one hand, sending a packet every now and then can dissuade a middle box from dropping the connection. On the other hand, if the connection is temporarily not working and would have started working again a few minutes later the attempt to send an unnecessary packet could cause the connection to break permanently when it wouldn't otherwise have broken. I suppose that next time I have a recurring problem I should try both.

Sharing in case this can help you in the future, this is what works for me with Termux in .ssh/config

  ServerAliveInterval 120
  ServerAliveCountMax 30
  TCPKeepAlive yes