I noticed following behavior on two of my CENTOS7 machines .. (it also happened on a RHEL6 too).
Sometimes meanwhile i'm typing, my session freezes. What I've already figured out.
- Router shows connections as still active but as idle
- ping has recorded no errors while transmitting packets (server got pinged the whole login)
- I can immediately login to a second session, check the log and see following:
systemd-logind: New session 1 of user root. systemd: Started Session 1 of user root. systemd: Starting Session 1 of user root. systemd-logind: New session 2 of user root. systemd: Started Session 2 of user root. systemd: Starting Session 2 of user root.
So the session, seems to be opened anyway. As soon as I close the freezed window systemd-logind: Removed session 1.
appears.
There is no error "Write failed: Broken pipe", which appears after a disconnect.
I connect via BASH from my ubuntu desktop. It never happended to another Server. Just them. SSH is configured with default settings.
The machine is setted up new, it is a cluster and it appers on both nodes. Well actually the cluster isn't configured, they are just two server, setted up completey the same.
EDIT: I also noticed, that the freezed session is shown as active on the router, but idle since freeze, even with the session window closed ..
Best Answer
The configuration for this is in the file
~/.ssh/config
. To send the signal every four minutes to remotehost, put the following in your~/.ssh/config
.This is what I have in my
~/.ssh/config
.To enable it for all hosts use:
Host * ServerAliveInterval 240
Also make sure to run
chmod 600 ~/.ssh/config
, because the config file must not be world-readable.