【问题标题】:Can't commit to github remote via ssh after installing zsh安装 zsh 后无法通过 ssh 提交到 github 远程
【发布时间】:2020-06-13 19:07:48
【问题描述】:

我的 SSH 密钥与我的 Win10 机器和 Github 帐户配对,它在 Bash 上运行,但今天我通过 WSL 安装了 ZSH (oh-my-zsh),现在当我尝试推送时,我看到了下一个错误:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

ZSH中:

ssh -T -ai ~/.ssh/id_rsa git@github.com
git@github.com: Permission denied (publickey).

Bash 中:

$ ssh -T -ai ~/.ssh/id_rsa git@github.com
Hi UserName! You've successfully authenticated, but GitHub does not provide shell access.

【问题讨论】:

  • 你是通过 WSL 还是通过 Git Bash 使用 bash
  • 请使用“-v”选项运行 ssh 以打印调试信息,然后 edit 您的问题包含调试输出。

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


【解决方案1】:

我在 Ubuntu (WSL2) 上安装了 ZSH,以便按照您的步骤进行操作。就我而言,我可以通过 ZSH shell 推送到远程。 问题似乎出在您的 SSH 密钥WSL 内。 按照该步骤生成另一个密钥以在内部您的 WSL 中配对。

之所以如此,是因为您从 Windows 获取的第一个 SSH 密钥位于一个位置,而您现在需要的 SSH 密钥需要放在 WSL 中。

【讨论】:

    【解决方案2】:

    ohmyzsh/ohmyzsh issue 7891一样,检查~/.zshrc的内容,确保ssh没有别名。

    ssh -Tv 将如评论的那样向您显示在您的 zsh 会话中 ssh 命令所考虑的确切文件。

    【讨论】:

    • git push 会使用 ssh 别名还是二进制文件?
    • @phd 仅当有类似git config --global url."git@github.com:".insteadOf https://github.com/ 的配置时
    猜你喜欢
    • 1970-01-01
    • 2020-12-03
    • 2015-10-21
    • 2019-02-13
    • 2021-03-30
    • 2018-05-20
    • 2018-05-18
    • 2012-09-04
    相关资源
    最近更新 更多