# 错误：命令以退出状态 128 出错：git clone --filter=blob:none 'git@github.com:user/private-repo.git' /tmp/pip-req-build-xxxxx
  stderr: 克隆到 '/tmp/pip-req-build-xxxxx'...
  git@github.com: 权限被拒绝 (publickey)。
  fatal: 无法从远程仓库读取。

- **ID:** `pip/git-clone-ssh-key-error`
- **领域:** pip
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

pip 尝试通过 SSH 克隆私有 Git 仓库，但 SSH 代理缺少正确的私钥或密钥未添加到 SSH 代理，导致 '权限被拒绝 (publickey)'。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 24.0 | active | — | — |
| Git 2.43 | active | — | — |
| Python 3.12 | active | — | — |

## 解决方案

1. ```
   将 SSH 私钥添加到代理：'ssh-add ~/.ssh/id_ed25519'（或相应的密钥文件）。然后重试 pip install。
   ```
2. ```
   使用带有个人访问令牌的 HTTPS：pip install git+https://<token>@github.com/user/private-repo.git
   ```
3. ```
   通过设置 GIT_SSH_COMMAND 配置 pip 使用不同的 SSH 密钥：'GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" pip install git+ssh://git@github.com/user/private-repo.git'
   ```

## 无效尝试

- **** — Running 'pip install --upgrade pip' does not affect SSH key authentication; the error is in Git, not pip. (98% 失败率)
- **** — Setting PIP_REQUIRE_VIRTUALENV has no effect on Git authentication. (99% 失败率)
- **** — Using 'git config --global url."https://github.com/".insteadOf "git@github.com:"' may work for public repos but fails for private repos that need SSH key auth. (60% 失败率)
