pip auth_error ai_generated partial

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

ERROR: Command errored out with exit status 128: git clone --filter=blob:none '[email protected]:user/private-repo.git' /tmp/pip-req-build-xxxxx stderr: Cloning into '/tmp/pip-req-build-xxxxx'... [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

ID: pip/git-clone-ssh-key-error

其他格式: JSON · Markdown 中文 · English
88%修复率
90%置信度
1证据数
2024-01-10首次发现

版本兼容性

版本状态引入弃用备注
pip 24.0 active
Git 2.43 active
Python 3.12 active

根因分析

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

English

pip attempts to clone a private Git repository via SSH but the SSH agent lacks the correct private key or the key is not added to the SSH agent, resulting in 'Permission denied (publickey)'.

generic

官方文档

https://pip.pypa.io/en/stable/topics/vcs-support/#git

解决方案

  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://[email protected]/user/private-repo.git'

无效尝试

常见但无效的做法:

  1. 98% 失败

    Running 'pip install --upgrade pip' does not affect SSH key authentication; the error is in Git, not pip.

  2. 99% 失败

    Setting PIP_REQUIRE_VIRTUALENV has no effect on Git authentication.

  3. 60% 失败

    Using 'git config --global url."https://github.com/".insteadOf "[email protected]:"' may work for public repos but fails for private repos that need SSH key auth.