2026-04-02 23:12:36 +08:00

35 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: git身份认证成功但public key permission denied
createTime: 2024/07/02 15:24:51
tags:
- git
categories:
- 随记
---
参考[Authenticated but can't fetch or push](https://github.com/orgs/community/discussions/27456)
`git pull`的时候,明明配置好了 ssh-key但仍然报错
```bash
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 是不是正常的,如果返回内容中有:
```bash
Hi YourUserName! You've successfully authenticated, but GitHub does not provide shell access.
```
这样的内容,那说明 ssh 和 public key 配置没有问题。
可能导致这样问题的原因可能是 git 使用的内嵌 ssh而这个内嵌的 ssh 找不到我们配置的 rsa 密钥。
解决办法就是先卸载 git然后重新安装时注意选择`Use External OpenSSH`!
![external openssh](./extssh.png)