How to avoid SSH / SCP / SFTP connection resets during a long operation?

1. /etc/ssh/sshd_config

ClientAliveInterval 300
ClientAliveCountMax 3333
TCPKeepAlive yes

The run:

service sshd restart

2. /etc/ssh/ssh_config

Host *
    <...>
    ServerAliveInterval 300
    ServerAliveCountMax 3333