While the following config added into the cloud_init.cfg file (user data file for building an Ubuntu16/18 VM) does result in those 2 parameters getting their values increased from default 300 and 0 resp. as I want, it completely replaces the much bigger sshd_config contents that would have otherwise been placed (automatically) into /etc/ssh/sshd_config during VM deployment:
write_files:
- path: /etc/ssh/sshd_config
content: |
ClientAliveInterval 30000
ClientAliveCountMax 50
Is there perhaps a way of just getting these 2 parameter values alone changed in that config leaving the rest of it intact? Placing entire config with the 2 amended values into the cloud_init.cfg didn't work, probably because of some formatting issues. I suppose I should be looking to change those values in some sshd_config template used to create sshd_config and not directly in the latter file itself.
Many thanks in advance!
ClientAliveIntervalvalue apart from the default0will prevent idle disconnects. But raising this to 50 x 30000 (almost 18 days!), will not only prevent idle but also unresponsive disconnects. If the client goes down for whatever reason (turned off, internet down, etc) the server will not take any action (for 18 days), and the connections on the server side will remain open. So when the client re-connects (as a new connection), if it tries for example to re-setup reverse tunnels on server, it will fail because those ports will still be "in use" by a zombie connection. – MestreLion Jun 06 '23 at 05:13autosshreally helps) , and the the server can free up the used ports. Might not be too relevant with ordinary connections, but if you're setting up tunnels it becomes paramount for the server to make those ports available again. – MestreLion Jun 06 '23 at 05:22