首页 > 解决方案 > 安装 zsh 后无法通过 ssh 提交到 github 远程

问题描述

我有 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).

重击中

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

标签: gitgithubsshzshwindows-subsystem-for-linux

解决方案


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

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


推荐阅读