fix: don't let ssh-keyscan abort SSH git clones#4605
Open
weibeu wants to merge 1 commit into
Open
Conversation
cloneGitRepository runs `ssh-keyscan <host> >> known_hosts` as one step of a `set -e` script. Hosts whose SSH endpoint waits for the client's identification string first — Hugging Face's hf.co among them — never complete the keyscan handshake, so it exits 1 and `set -e` aborts the deploy before `git clone` ever runs. Make ssh-keyscan non-fatal and let the real ssh client record the host key on first connect (StrictHostKeyChecking=accept-new), which reaches hosts ssh-keyscan can't scan. Same TOFU trust model, so no regression; GitHub/GitLab/Gitea still pre-seed and verify known_hosts as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
Custom Git deploys over SSH abort before
git clonewhen the Git host doesn't answerssh-keyscan.cloneGitRepositoryrunsssh-keyscan -p <port> <host> >> known_hostsas one step of aset -escript; Hugging Face'shf.coendpoint never completes the keyscan handshake — it waits for the client's SSH identification string before sending its own, whilessh-keyscanwaits for the server's — so it exits1andset -ekills the deploy. The clone itself works fine; a realssh/gitclient sends its banner first, sohf.coresponds.Two minimal changes in
utils/providers/git.ts:ssh-keyscan … || true— it is a best-effort convenience; its exit code should not gate the clone.-o StrictHostKeyChecking=accept-newonGIT_SSH_COMMAND— let the real ssh client record the host key on first connect (it reaches hostsssh-keyscancannot scan). Same TOFU trust model as a blindssh-keyscan >> known_hosts, so no security regression; a changed host key is still refused.GitHub/GitLab/Gitea are unaffected — they answer
ssh-keyscan, soknown_hostsis still pre-seeded and verified as before.Checklist
Before submitting this PR, please make sure that:
canarybranch.git clone git@hf.co:<org>/<repo>succeeds (host key recorded on first connect, exit 0); without them theset -escript aborts at thessh-keyscanstep andgit clonenever runs.Issues related (if applicable)
closes #4604