ERROR
pip
auth_error
ai_generated
true
ERROR: Command errored out with exit status 128: git clone --filter=blob:none '[email protected]:user/private-repo.git' /tmp/pip-install-xxx/package. Check the logs for full command output. stderr: [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
ID: pip/vcs-git-clone-permission-denied-public-key
85%Fix Rate
90%Confidence
1Evidence
2023-06-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pip 23.0 | active | — | — | — |
| pip 23.2 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| git 2.40 | active | — | — | — |
Root Cause
Pip tries to clone a private Git repository via SSH, but the SSH key is not configured or not accepted by the remote server, causing a public key authentication failure.
generic中文
Pip 尝试通过 SSH 克隆私有 Git 仓库,但 SSH 密钥未配置或未被远程服务器接受,导致公钥认证失败。
Official Documentation
https://pip.pypa.io/en/stable/topics/vcs-support/Workarounds
-
90% success Generate an SSH key pair and add the public key to your GitHub account: ssh-keygen -t ed25519 -C '[email protected]'; cat ~/.ssh/id_ed25519.pub (copy output); go to GitHub Settings > SSH and GPG keys > New SSH key; paste and save. Then retry pip install.
Generate an SSH key pair and add the public key to your GitHub account: ssh-keygen -t ed25519 -C '[email protected]'; cat ~/.ssh/id_ed25519.pub (copy output); go to GitHub Settings > SSH and GPG keys > New SSH key; paste and save. Then retry pip install.
-
85% success Use HTTPS instead of SSH for the Git URL in the requirements file: replace git+ssh://[email protected]/user/private-repo.git with git+https://github.com/user/private-repo.git and use a personal access token (PAT) for authentication: pip install git+https://<PAT>@github.com/user/private-repo.git
Use HTTPS instead of SSH for the Git URL in the requirements file: replace git+ssh://[email protected]/user/private-repo.git with git+https://github.com/user/private-repo.git and use a personal access token (PAT) for authentication: pip install git+https://<PAT>@github.com/user/private-repo.git
-
100% success If the repository is public, change the URL to use the public HTTPS clone URL without authentication: git+https://github.com/user/public-repo.git
If the repository is public, change the URL to use the public HTTPS clone URL without authentication: git+https://github.com/user/public-repo.git
中文步骤
生成 SSH 密钥对并将公钥添加到您的 GitHub 帐户:ssh-keygen -t ed25519 -C '[email protected]';cat ~/.ssh/id_ed25519.pub(复制输出);转到 GitHub 设置 > SSH 和 GPG 密钥 > 新建 SSH 密钥;粘贴并保存。然后重试 pip install。
在 requirements 文件中使用 HTTPS 而不是 SSH 作为 Git URL:将 git+ssh://[email protected]/user/private-repo.git 替换为 git+https://github.com/user/private-repo.git,并使用个人访问令牌(PAT)进行身份验证:pip install git+https://<PAT>@github.com/user/private-repo.git
如果仓库是公开的,将 URL 更改为使用无需身份验证的公共 HTTPS 克隆 URL:git+https://github.com/user/public-repo.git
Dead Ends
Common approaches that don't work:
-
Using pip install with --no-deps to skip VCS dependencies
95% fail
This only avoids the error for the current install but leaves the missing dependency unresolved, causing import errors later.
-
Adding the SSH key to the ssh-agent with ssh-add without checking the key is correct for the repository
60% fail
If the key is not added to the GitHub account or is the wrong key type, authentication still fails.
-
Setting GIT_SSH_COMMAND='ssh -v' to debug but not fixing the underlying key issue
90% fail
Debugging alone does not resolve the authentication failure.