When I use a Linux server on my house and I access it from the Internet, I can keep the terminal window open with an SSH connection for as long as I want. However, when I use a Linux server on cloud services like AWS or Oracle cloud, my terminal always freezes after some minutes I leave it idle. That bothers me a lot because many times I'm still researching about the subject that I'm doing and then my SSH connection with the cloud is frozen when I come back. That results in me having to close the terminal and reopen the connection with a new one, and then reopening everything again, so I end up spending a lot of time on this during the day. I've looked in the file
/etc/ssh/sshd_config if I could find anything related to connection timeouts to understand why it happens but I didn't find anything.
Also, I've found this question here on Unix Exchange that seems related. According to the accepted answer, if I use the parameter
-o TCPKeepAlive=true while connecting with
ssh this problem would be solved. In my case, it didn't solve the problem at all, the connection still freezes after some time idle, the command that I used was something like the following:
ssh -i myprivatekey -o TCPKeepAlive=true user@serverip
Is there any configuration I can change on my computer or the server to solve this problem? How can I make an SSH connection stop freezing after being idle for a while?