ssh: connection reset by peer

Just a quick tips I find out recently to avoid my ssh connection to time out with the annoying « Connection reset by peer » error message.

On the client:

Edit /etc/ssh/ssh_config (/etc/defaults/etc/ssh_config if your using Cygwin)
Add ServerAliveInterval if not already there and make sure to provide a number of seconds not to important:
For instance, my config is:

ServerAliveInterval 180

This indicates the client send packet to the server every 180 seconds in case of unactivity.

On the server:

Same thing, make sure you have, within /etc/ssh/sshd_config, something like:

TCPKeepAlive yes
ClientAliveInterval 180