pip auth_error ai_generated partial

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

Also available as: JSON · Markdown · 中文
88%Fix Rate
90%Confidence
1Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 24.0 active
Git 2.43 active
Python 3.12 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 85% success Add the SSH private key to the agent: 'ssh-add ~/.ssh/id_ed25519' (or appropriate key file). Then retry pip install.
    Add the SSH private key to the agent: 'ssh-add ~/.ssh/id_ed25519' (or appropriate key file). Then retry pip install.
  2. 95% success Use HTTPS with personal access token: pip install git+https://<token>@github.com/user/private-repo.git
    Use HTTPS with personal access token: pip install git+https://<token>@github.com/user/private-repo.git
  3. 80% success Configure pip to use SSH with a different key by setting GIT_SSH_COMMAND: 'GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" pip install git+ssh://[email protected]/user/private-repo.git'
    Configure pip to use SSH with a different key by setting GIT_SSH_COMMAND: 'GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" pip install git+ssh://[email protected]/user/private-repo.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'

Dead Ends

Common approaches that don't work:

  1. 98% fail

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

  2. 99% fail

    Setting PIP_REQUIRE_VIRTUALENV has no effect on Git authentication.

  3. 60% fail

    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.