When my connection has been idle for some time, the remote host closes the connection. I try to type a new command, it hangs, then closes the connection. How can I keep the ssh connection active for longer?$ ssh root@host.comLast login: Tue Jan  3 03:09:39 2017 from c-99-99-99-99.hsd1.xx.comcast.net[root@ip-172-99-99-99 ~]# groupsroot bin daemon sys adm disk wheel[root@ip-172-99-99-99 ~]# usersroot root[root@ip-172-99-99-99 ~]# less /etc/passwd[root@ip-172-99-99-99 ~]# Connection reset by 52.99.99.99 port 22The remote is CentOS on Amazon (AWS) and local is Cygwin.
SSH: connection reset after idle for some time
centos;ssh;sshd;cygwin;timeout
Because your last login was from comcast.net I am guessing that you are connecting from a home system where you are behind a router which is doing NAT. A problem that a system doing NAT has is knowing when the connection is no longer wanted. If the connection is taken down cleanly then there is no problem but if the two machines just reboot then there is no signal to the NAT box that this has happened. Therefore your typical NAT box has timers which say if there is no traffic for an hour then the two endpoints clearly are not going to send anything more and so recycles the resources that the NAT was taking.So the thing to do is send some traffic every once in a while. The simplest way assuming you are using the openssh implementation on your cygwin machine is to enable TCPKeepAlive. replacessh root@host.comwithssh -o TCPKeepAlive=true root@host.comFor long term use you are better setting up a ~/.ssh/config file. host fred     hostname host.com     user root     TCPKeepAlive=trueand then you will be able to say just ssh fred to connect to the machine with the needed option.