【问题标题】:Unable to use git in WSL. C:\Windows\System32\OpenSSH\ssh.exe: not found无法在 WSL 中使用 git。 C:\Windows\System32\OpenSSH\ssh.exe:未找到
【发布时间】:2021-10-21 00:15:46
【问题描述】:

所以我在 Windows 10 上,不久前我决定使用 WSL,这样我就可以获得 zsh。但是,现在我不能再从我的 wsl 终端使用 git,即我不能再从远程 repo 中使用git pull。当我尝试时,我得到以下...

'C:\Windows\System32\OpenSSH\ssh.exe': 1: C:\Windows\System32\OpenSSH\ssh.exe: not found
fatal: Could not read from remote repository.

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

此类操作在 bash 和 GitHub Desktop 中运行良好。为什么 WSL 尝试从 Windows 使用 OpenSSH 应该是 Linux 吧?

我正在努力寻找有关此问题的信息,因此非常感谢任何帮助。如果我可以提供更多信息,请告诉我。

【问题讨论】:

  • whereis ssh(在 WSL 中)的输出是什么?
  • 我很惊讶 WSL 没有自带原生 ssh 和 git 实现。我还没有尝试过 WSL,但如果可以在 WSL 中安装 Git,我会尝试。
  • whereis ssh 输出 ssh: /usr/bin/ssh /etc/ssh /mnt/c/WINDOWS/System32/OpenSSH/ssh.exe /usr/share/man/man1/ssh.1.gz 我在 WSL 中有可用的 Git,但我无法从远程仓库中提取

标签: windows git ssh windows-subsystem-for-linux


【解决方案1】:

像这样更改值“core.sshCommand”后我得到了同样的错误:

git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

在我的文件 ~/.gitconfig 中,我禁用了如下所示的换行符:

#[core]
#       sshCommand = 'C:\\Windows\\System32\\OpenSSH\\ssh.exe'

然后,当您在 git 存储库中时,如果您遇到同样的问题,请检查您的 my-project/.git/config 文件,如果有新配置,请按上述方式禁用它。

就我而言,它有效:-)
祝你有美好的一天

【讨论】:

    【解决方案2】:

    仔细检查您是否有指向 C:\Windows\System32\OpenSSH\ssh.exe 的环境变量 GIT_SSH:这在 WSL 会话中不是有效路径。

    取消设置。
    之后,取决于使用的 Windows 10(1709?1809?20H1?...),以及使用的 WSL(WSL1 还是 WSL2?)。

    【讨论】:

    猜你喜欢
    • 2020-04-22
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    • 2018-07-07
    • 2020-05-29
    相关资源
    最近更新 更多