Yet it is high enough to avoid most network blips in practise. I set the ClienAliveInterval to 3600 (one hour), which is low enough to work with the default timeouts in ip-filter (on NetBSD), iptables (on OpenWRT), Cisco PIX and Cisco routers with CBAC. This is because TCP will abort the connection after it fails to receive a response to the packet with the SSH keep alive probe. You could fix the problem for all long-lived TCP connections by adjusting the timeout on the firewall or router to a more reasonable value.īy sending traffic every 60 seconds over the connection you are likely to run into a new problem: if any physical link in the network between the client and the server is down for a couple of minutes, the connection is guaranteed to die. You are probably working around a NAT translation or dynamic firewall rule timeout problem by making sure traffic is sent more often than the timeout. I knew I had blogged about ssh timeout problems before, but I hadn’t mentioned the client fix so it’s worth a revisit! I prefer this way because I login to several machines every day, and I don’t have root access to all of them.
That will send send a message to the server every 60 seconds, keeping the connection open. As root on your desktop (or client) machine, edit /etc/ssh/ssh_config and add the line: The other way, and easier and safer way is for your desktop machine to send those keep alive messages.This option applies to protocol version 2 only.ĭon’t forget to restart sshd on the server after you save the file. The default is 0, indicating that these messages will not be sent to the client. Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. On the server, login as root and edit /etc/ssh/sshd_config and add the line:.
You’ll need root access, so for most people it’s probably safer to do the client fix rather than the server fix. You only need to do one of them so choose whichever one is easiest for you. Read from remote host ocaoimh.ie: Connection reset by peer
If you use ssh a lot, you may have noticed that your ssh session times out and you’re logged out every once in a while.