I have launched an EC2 instance running ubuntu 16.4 and able to connect using Pytty SSH with Key pair. The issues is even when I'm executing some commands - that is actively working, the session closes every 20 seconds. If I restart the session, I can connect, closes after 20 seconds again. I tried to configure "Seconds between keepalives" to 10 or 20 or any other number, save the session, reopen the connection, I still have the same problem. I also tried to enable TCP_KeepAlives checked, but the problem persists.
I was able to work properly earlier, but I am having the above problem for the past 2 days.