It has a very cool logo in which Puffy is really dressed to kill 😄
Well, it's uncomfortable if the connections are killed frequently while maintaining servers.
This post shows how to configure to keep the connection alive.
The server/client alive messages are used in order to keep
ssh connection alive.
They are sent between clients and servers to request a response.
Besides, they are sent through the encrypted channel. (It's nice!)
What to actually do is just to edit the config file about them in either a client or a server.
Of course, it's OK to edit both.
Edit the config file like this:
$ nvim ~/.ssh/config
ServerAliveInterval means a timeout interval in seconds.
The default value is 0, which indicates no messages to request a response are sent from a client to a server.
Optionally, cofiguration of
ServerAliveCountMax is available:
ServerAliveCountMax means the maximum counts to send the messages.
The default value is 3.
For example, with the above settings, the server alive messages work like these:
#1. When 60 seconds are passed, the 1st message is sent from the client to the server.
- Client: "Are you alive?"
- Server: "Yes, I am!"
#2. When 60 * 2 = 120 seconds are passed, the 2nd message is sent.
#3. When 60 * 3 = 180 seconds are passed, the 3rd message is sent.
#4. When 60 * 4 = 240 seconds are passed, the 4th message is sent.
#5. When 60 * 5 = 300 seconds are passed, the 5th message is sent.
After all, if the server becomes unresponsive,
ssh will disconnect after approximately 300 seconds.
The server-side configuration is used for the client alive messages, whose settings are almost the same to the server ones.
The remarkable difference is that the alive messages are sent from the servers to the clients and the servers will receive any messages back from the clients.
sshd_config like this:
# nvim /etc/ssh/sshd_config
Happy serving 🕊