35 lines
1.0 KiB
Markdown
35 lines
1.0 KiB
Markdown
---
|
||
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`!
|
||
|
||

|