Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows runner: ssh cannot resolve submodule hostname #148

Open
audricschiltknecht opened this issue Nov 3, 2022 · 4 comments
Open

Windows runner: ssh cannot resolve submodule hostname #148

audricschiltknecht opened this issue Nov 3, 2022 · 4 comments

Comments

@audricschiltknecht
Copy link

Hello,

I've setup an action for a private repository with (private) submodules. I'm using the deploy keys with comments as per the docs.

Everything works fine on the ubuntu-latest runner but when I switch to windows-latest it seems that ssh is not using the proper hostname and instead use the one including the keyname, resulting in an obvious "Name not known" error:

   17:58:32.064475 run-command.c:655       trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL git@key-<SHA>.github.com 'git-upload-pack '\''<ORG>/<SUBMODULE>'\'''
  Cloning into 'D:/a/<REPO>/<REPO>/<SUBMODULE>'...
  ssh: Could not resolve hostname key-<SHA>.github.com: Name or service not known
  Error: fatal: Could not read from remote repository.

This seems a bit weird as I haven't seen anyone mentioning that problem in the issues, so I'm wondering if it could be a config problem instead?

Thanks!

@audricschiltknecht
Copy link
Author

I've dug a bit deeper and it seems there is something going on with the home path.
The ssh config is created in C:\Users\runneradmin/.ssh/ as seen in the logs:

2022-11-03T19:53:35.8735847Z ##[group]Run webfactory/[email protected]
2022-11-03T19:53:35.8736307Z with:
2022-11-03T19:53:35.8738032Z   ssh-private-key: ***

2022-11-03T19:53:35.8738308Z env:
2022-11-03T19:53:35.8738526Z   GIT_TRACE: 1
2022-11-03T19:53:35.8738759Z   GIT_CURL_VERBOSE: 1
2022-11-03T19:53:35.8739029Z   GIT_SSH_COMMAND: ssh -vvv
2022-11-03T19:53:35.8739277Z ##[endgroup]
2022-11-03T19:53:39.2552847Z Adding GitHub.com keys to C:\Users\runneradmin/.ssh/known_hosts

but it appears that SSH is expecting it somewhere else when we clone the submodule:

2022-11-03T19:53:52.8591485Z OpenSSH_9.0p1, OpenSSL 1.1.1q  5 Jul 2022
2022-11-03T19:53:52.8591959Z debug1: Reading configuration data /etc/ssh/ssh_config
2022-11-03T19:53:52.8592696Z debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/d/a/_temp/<some uuid>/.ssh/known_hosts'
2022-11-03T19:53:52.8593507Z debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/d/a/_temp/<some uuid>/.ssh/known_hosts2'
2022-11-03T19:53:52.8594366Z debug2: resolving "key-<SHA>.github.com" port 22
2022-11-03T19:53:52.8595246Z debug3: resolve_host: lookup key-<SHA>.github.com:22
2022-11-03T19:53:52.8596185Z ssh: Could not resolve hostname key-<SHA>.github.com: Name or service not known
2022-11-03T19:53:52.8620858Z ##[error]fatal: Could not read from remote repository.
2022-11-03T19:53:52.8628627Z 
2022-11-03T19:53:52.8628905Z Please make sure you have the correct access rights

@audricschiltknecht
Copy link
Author

Finally found the culprit: https://github.com/actions/checkout/blob/v3.1.0/src/git-auth-helper.ts#L122

checkout is overriding $HOME before doing the checkout. It's copying .gitconfig but not the .ssh folder :|

@audricschiltknecht
Copy link
Author

For reference, I've quickly hacked the action to change the system-wide config on windows: https://github.com/audricschiltknecht/ssh-agent/tree/fix-path-windows

This is not ideal as I don't know what happens with the config put there at the end of the action or even if for self-hosted runners this will work.

@DilumAluthge
Copy link
Contributor

DilumAluthge commented Nov 14, 2024

I have encountered a bug on Windows that seems similar to this issue, but my workaround is different. Specifically, I'm able to resolve the bug by setting GIT_SSH_COMMAND as described here: #230 (comment)

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

No branches or pull requests

2 participants