From 65387779097a59a98d569e4efc0b05b7134b262a Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Mon, 10 Oct 2022 15:33:14 -0400 Subject: [PATCH] ci(ssh): avoid ssh timeouts from the server Motivation: We've been trying multiple solutions to our SSH connection issues, our last try solving this issues was PR https://github.com/ZcashFoundation/zebra/pull/5367/files Depends-On: #5367 Expected behavior: An SSH connection should not be terminated by the server, the connection must be kept alive indefinitely until it's killed by GitHub Actions Solution: Disable TCP keepalive messages from the server and set `ClientAliveCountMax` to 0, which disables connection termination --- .github/workflows/scripts/gcp-vm-startup-script.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/gcp-vm-startup-script.sh b/.github/workflows/scripts/gcp-vm-startup-script.sh index ee0f060f6f6..cb94720df16 100755 --- a/.github/workflows/scripts/gcp-vm-startup-script.sh +++ b/.github/workflows/scripts/gcp-vm-startup-script.sh @@ -2,7 +2,10 @@ # Increase the Google Cloud instance sshd connection limit # # This script appends 'MaxStartups 500' to /etc/ssh/sshd_config allowing up to 500 -# unauthenticated connections to Google Cloud instances. +# unauthenticated connections to Google Cloud instances +# +# It also adds 'ClientAliveCountMax 0' and 'TCPKeepAlive no' to avoid SSH timeout from +# the server ps auxwww | grep sshd echo sudo grep MaxStartups /etc/ssh/sshd_config @@ -11,6 +14,8 @@ sudo cat /etc/ssh/sshd_config echo echo 'Modifying config:' echo 'MaxStartups 500' | sudo tee --append /etc/ssh/sshd_config \ +echo 'TCPKeepAlive no' | sudo tee --append /etc/ssh/sshd_config \ +echo 'ClientAliveCountMax 0' | sudo tee --append /etc/ssh/sshd_config \ || \ (echo "updating instance sshd config failed: failing test"; exit 1) sudo grep MaxStartups /etc/ssh/sshd_config