安装 zsh 后无法通过 ssh 提交到 github 远程

Can't commit to github remote via ssh after installing zsh

我将 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.

ohmyzsh/ohmyzsh issue 7891 一样,请检查您的 ~/.zshrc 的内容,并确保 ssh.

没有别名

如评论所述,ssh -Tv 将向您准确显示 zsh 会话中的 ssh 命令考虑了哪些文件。

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

这是因为您来自 Windows 的第一个 SSH 密钥位于一个位置,而您现在需要的 SSH 密钥需要放在 WSL 中。

有同样的问题

已成功通过 bash 终端进行身份验证。

但是当尝试使用 zsh 时它给了我 权限被拒绝 或尝试使用其他 git 帐户 问题:在 zsh 中 ssh-add 不工作。 你必须在你的 ~/.zshrc 文件中添加 ssh-agent 插件

plugins=( git ssh-agent)