- Newest
- Most votes
- Most comments
The issue you're experiencing with your SSH connection to your EC2 instance closing after 60 seconds of inactivity is likely related to a client-side configuration rather than a server-side setting, since your coworkers are not experiencing the same problem.
To address this issue, you can try the following solutions:
-
Enable keepalives on your SSH client: If you're using PuTTY, go to the Connection page of the PuTTY Configuration and set "Seconds between keepalives" to 59 seconds. This will send a small packet every 59 seconds to keep the connection alive.
-
If you're using a standard OpenSSH client, you can add the following lines to your ~/.ssh/config file or include them in your SSH command:
ServerAliveInterval 59 ServerAliveCountMax 3
This will send a packet every 59 seconds and allow up to 3 missed responses before disconnecting.
-
If enabling keepalives doesn't resolve the issue, you can try disabling Nagle's algorithm in your SSH client configuration. In PuTTY, this option is also found on the Connection page of the PuTTY Configuration.
-
Check your local firewall or security software to ensure it's not interfering with your SSH connection.
-
Verify that your network connection is stable and not dropping packets.
If none of these solutions work, you may want to compare your SSH client version and configuration with those of your coworkers to identify any differences that could be causing the issue.
Remember that EC2 Instance Connect sessions typically last for an hour, so the 60-second disconnect you're experiencing is likely not related to the EC2 instance itself but rather to your local configuration or network conditions.
If the problem persists, you may want to consult with your IT department or AWS support for further assistance in troubleshooting your specific setup.
Sources
Troubleshoot issues connecting to your Amazon EC2 Linux instance - Amazon Elastic Compute Cloud
Disconnect from the EC2 Serial Console - Amazon Elastic Compute Cloud
Connect to your Linux instance using EC2 Instance Connect - Amazon Elastic Compute Cloud

I've check the firewall and it seems normal. The difference that I get between my coworkers is the openSSH version
Mine: OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022
Theirs: OpenSSH_8.2p1 Ubuntu-4ubuntu0.11, OpenSSL 1.1.1f 31 Mar 2020
I've accessed a Raspberry PI inside my network, and the connection didn't drop. Is this problem still related to my pc, openssh version somehow?
Remember that EC2 Instance Connect sessions typically last for an hour ---> How to increase this limit? I get Websocket Closure Reason: Connection exceeded session timeout after an hour and it kicks me out.