外观
git身份认证成功但public key permission denied
2024-07-02
参考Authenticated but can't fetch or push
在git pull
的时候,明明配置好了 ssh-key,但仍然报错:
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.
首先使用ssh -vT git@github.com
验证 ssh 和 public key 是不是正常的,如果返回内容中有:
Hi YourUserName! You've successfully authenticated, but GitHub does not provide shell access.
这样的内容,那说明 ssh 和 public key 配置没有问题。
可能导致这样问题的原因可能是 git 使用的内嵌 ssh,而这个内嵌的 ssh 找不到我们配置的 rsa 密钥。
解决办法就是先卸载 git,然后重新安装时注意选择Use External OpenSSH
!
