From 1905221195dd62b98a55d0ecb5fd651cd83e4b2b Mon Sep 17 00:00:00 2001 From: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Date: Sat, 29 Aug 2026 12:06:58 +0200 Subject: [PATCH] fix(ssh): keep the github.com connection alive through slow pre-push hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git push opens the SSH connection to github.com before running the pre-push hook, then leaves it fully idle for the hook's entire duration. Under heavy concurrent machine load, hooks routinely took long enough that GitHub's idle-connection timeout closed the SSH session mid-hook — the push then silently failed to transfer after printing "Safe to push," with only a stray "Connection to github.com closed by remote host." to explain it. Reproduced 4x in one session before diagnosing via GIT_TRACE=1. ServerAliveInterval/CountMax keep the connection alive during that idle window. --- .ssh/config | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.ssh/config b/.ssh/config index 51d1059..ed1c6f8 100644 --- a/.ssh/config +++ b/.ssh/config @@ -4,3 +4,13 @@ Host github.com User git IdentityFile ~/.ssh/github_ed25519 IdentitiesOnly yes + # git push opens this connection BEFORE running the pre-push hook, then + # leaves it fully idle for the hook's entire duration. Found 2026-08-29: + # under heavy concurrent machine load (~80 sessions), hooks routinely ran + # long enough that GitHub's idle-connection timeout killed the SSH session + # while the hook was still running — the push then silently failed to + # transfer after printing "Safe to push," with only a stray "Connection to + # github.com closed by remote host." in the log to explain it. Active + # keepalives during that idle window prevent the drop. + ServerAliveInterval 30 + ServerAliveCountMax 10