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 50Is 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!
1 Answer
Apparently adding this one into /etc/ssh/sshd_config does the trick (tested, works):
runcmd: - sed -i 's/ClientAliveInterval 300/ClientAliveInterval 30000/' /etc/ssh/sshd_config - sed -i 's/ClientAliveCountMax 0/ClientAliveCountMax 50/' /etc/ssh/sshd_config - service ssh restart