You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running in containers, the SSH clones are currently completely broken. Nobody noticed so far, because the default cloning mode is HTTPS, not SSH. Cloning via SSH in a container is a rare combo I guess.
The issue has to do with the ~/.ssh/known_hosts file - or lack thereof. The action is supposed to populate the ~/.ssh/known_hosts with SSH host keys for Github - but this is, somehow, not happening.
I suspect the issue is that action/checkout does this:
`Temporarily overriding HOME='${this.temporaryHomePath}' before making global git config changes`
)
This code changes the HOME directory to a temporary one, and that new HOME is used for git invocations. The actions, however, doesn't copy the contents of the old HOME/.ssh to the newly created dir.
This logic seems to be called after the ~/.ssh/known_hosts file is populated, so the file is never actually used.
What makes things even worse is that the action uses a random directory name for the new HOME - so we can't even pre-populate it with a fixed data.
Solution
I propose the following plan:
Add an input to enable copying user-specified files into that new HOME dir.
Copy the .ssh from the real HOME to temp HOME by default.
Consider ways to eliminate touching the HOME in the first place, or to provide an opt-out from it.
Implement automatic tests for cloning SSH in containers. The fact that this major feature is broken is not normal. Github Actions were not born yesterday, the investment into proper QA tooling is long overdue.
Workaround
For now, I've found a workaround that fits our use-case: manually write the /etc/ssh/ssh_known_hosts.
The text was updated successfully, but these errors were encountered:
MOZGIII
changed the title
Container builds: SSH clones are broken; action does not populate ~/.ssh/known_hosts properly - and there's no way to provide it yourself
Container builds: SSH clones are broken; action does not populate ~/.ssh/known_hosts properly
Apr 30, 2025
Problem
When running in containers, the SSH clones are currently completely broken. Nobody noticed so far, because the default cloning mode is HTTPS, not SSH. Cloning via SSH in a container is a rare combo I guess.
The issue has to do with the
~/.ssh/known_hosts
file - or lack thereof. The action is supposed to populate the~/.ssh/known_hosts
with SSH host keys for Github - but this is, somehow, not happening.I suspect the issue is that
action/checkout
does this:checkout/src/git-auth-helper.ts
Lines 119 to 121 in 85e6279
This code changes the
HOME
directory to a temporary one, and that newHOME
is used forgit
invocations. The actions, however, doesn't copy the contents of the oldHOME/.ssh
to the newly created dir.This logic seems to be called after the
~/.ssh/known_hosts
file is populated, so the file is never actually used.What makes things even worse is that the action uses a random directory name for the new
HOME
- so we can't even pre-populate it with a fixed data.Solution
I propose the following plan:
HOME
dir..ssh
from the realHOME
to tempHOME
by default.HOME
in the first place, or to provide an opt-out from it.Workaround
For now, I've found a workaround that fits our use-case: manually write the
/etc/ssh/ssh_known_hosts
.The text was updated successfully, but these errors were encountered: