Skip to content

Fix git SSH push inside guest VMs#59

Merged
JAORMX merged 1 commit intomainfrom
fix/git-ssh-push
Mar 18, 2026
Merged

Fix git SSH push inside guest VMs#59
JAORMX merged 1 commit intomainfrom
fix/git-ssh-push

Conversation

@JAORMX
Copy link
Copy Markdown
Contributor

@JAORMX JAORMX commented Mar 17, 2026

Summary

Three issues prevented git push over SSH from working inside the microVM, even though SSH agent forwarding was correctly set up by go-microvm v0.0.23:

  • Missing ~/.ssh/known_hosts — the guest had no host keys for github.com, gitlab.com, or bitbucket.org, causing SSH to reject connections with "Host key verification failed". Added InjectSSHKnownHosts rootfs hook with verified keys (ed25519, ecdsa, rsa) for all three providers.

  • URL sanitizer stripping SSH usernamessanitizeURL treated all url.User info as credentials, turning ssh://git@github.com/org/repo into ssh://github.com/org/repo. Fixed to only strip when a password is present; username-only URLs (SSH key auth) are preserved.

  • Missing insteadOf URL rewrites — the host's global ~/.gitconfig [url "git@github.com:"].insteadOf rules were not forwarded to the guest. Repos with HTTPS remotes that relied on host-side rewriting to SSH could not use SSH agent forwarding. Added URLRewrite parsing to HostIdentityProvider and injection into the guest .gitconfig.

Test plan

  • Verified SSH_AUTH_SOCK is set inside the VM
  • Verified ssh -T git@github.com authenticates successfully (known_hosts + agent forwarding)
  • Verified git remote -v shows SSH URL via insteadOf rewrite
  • Verified ~/.gitconfig inside guest contains the [url].insteadOf rule
  • All new unit tests pass (TestInjectSSHKnownHosts_*, TestParseURLRewrites, TestHostIdentityProvider_URLRewrites, sanitizer SSH URL tests)
  • CI passes

🤖 Generated with Claude Code

Three issues prevented git push over SSH from working inside the
microVM:

1. Missing ~/.ssh/known_hosts — the guest had no host keys for
   github.com, gitlab.com, or bitbucket.org, causing SSH to reject
   connections with "Host key verification failed". Added a new
   InjectSSHKnownHosts rootfs hook that writes verified host keys
   (ed25519, ecdsa, rsa) for all three providers.

2. URL sanitizer stripping SSH usernames — sanitizeURL treated all
   url.User info as credentials and stripped it, turning
   ssh://git@github.com/org/repo into ssh://github.com/org/repo.
   Fixed to only strip user info when a password is present.

3. Missing insteadOf URL rewrites — the host's global gitconfig
   [url "git@github.com:"].insteadOf rules were not forwarded to the
   guest, so repos with HTTPS remotes that relied on host-side
   rewriting to SSH could not use SSH agent forwarding. Added
   URLRewrite parsing to HostIdentityProvider and injection into
   the guest's .gitconfig.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX force-pushed the fix/git-ssh-push branch from eb21446 to db5fb1a Compare March 17, 2026 15:08
@JAORMX JAORMX merged commit 37ad23d into main Mar 18, 2026
7 checks passed
@JAORMX JAORMX deleted the fix/git-ssh-push branch March 18, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants