Skip to content

Windows: unable to clone, with error message ssh: Could not resolve hostname key-<SHA>.github.com: Name or service not known #230

@DilumAluthge

Description

@DilumAluthge

I see a few open issues that look similar to this, but not exactly the same, so I figured I'd open a new issue. Feel free to close if this is a duplicate.

For example, this might be a duplicate of #148.

Version info

I am able to reproduce this bug using version v0.9.0 (dc588b6) of this action.

Description of the bug

On Windows, I am unable to clone, with the error message looking something like this:

ssh: Could not resolve hostname key-<SHA>.github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I've only encountered this bug on Windows. I have not seen this bug on Linux or macOS.

I do not have any Git submodules.

Workaround

I'm able to resolve the bug by setting the GIT_SSH_COMMAND environment variable as follows:

- name: Set GIT_SSH_COMMAND on Windows
  if: runner.os == 'Windows'
  shell: bash
  run: |
    echo "GIT_SSH_COMMAND=ssh -F /c/Users/MY_USERNAME/.ssh/config -o \"UserKnownHostsFile /c/Users/MY_USERNAME/.ssh/known_hosts\"" >> "${GITHUB_ENV:?}"

Replace /c/Users/MY_USERNAME/ with the correct home directory. On GitHub-hosted Windows runners, this will probably be /c/Users/runneradmin. For self-hosted Windows runners, this will depend on your CI setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions