SSH Connection Reset By Peer

If ever you see the following when using SSH and it all seems inexplicable.
Read from remote host www.somehwhere.com: Connection reset by peer
There may be a quick cure (caveat, your mileage may vary). Some routers, i.e. Linksys WRT54G will close a connecting that does not appear busy. So far I have found that if I add
ServerAliveInterval = 300
ServerAliveCountMax = 300
to my /etc/ssh/ssh_config file then everything is fine.
Basically we are send a message to the server every “ServerAliveInterval” seconds and if the client has not had a response after “ServerAliveCountMax” messages then the connection will disconnect. This makes the connection look active to hardware that thinks it’s doing you a favour by disconnecting idle connections.
see “man ssh_config” for more details.
I have also noticed the following method but have not tried it
echo 300 > /proc/sys/net/ipv4/tcp_keepalive_time