Skip to content

known_hosts fail to load on Windows #6453

@ehuss

Description

@ehuss

Fetching a repo over SSH fails on Windows because it fails to find the home directory. This can happen when launching from Windows Powershell, Cmd, or other environments that do not set HOME.

Reproduction steps

Fetch an SSH repo from github.com using Windows Powershell or Cmd.

Expected behavior

libgit2 should be able to find the user's home directory. There are multiple ways to do that, though I'm not sure of the benefits of different approaches. Checking for USERPROFILE would probably be the easiest. The Powershell port of OpenSSH uses ProfileImagePath in the registry, falling back to GetWindowsDirectoryW if that fails. (Another option is SHGetFolderPathW, though I'm not sure I would recommend that.)

Also, I think a failure to load or process the known_hosts should not be a hard error if the user has also defined their own certificate_check_cb callback. That is, the code here shouldn't be a hard error.

Actual behavior

The error is:

invalid or unknown remote ssh hostkey

Version of libgit2 (release number or SHA1)

1.5.1

Operating system(s) tested

Windows 10 Pro

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