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

- **ID:** `pip/git-clone-ssh-key-error`
- **Domain:** pip
- **Category:** auth_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## 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)'.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 24.0 | active | — | — |
| Git 2.43 | active | — | — |
| Python 3.12 | active | — | — |

## Workarounds

1. **Add the SSH private key to the agent: 'ssh-add ~/.ssh/id_ed25519' (or appropriate key file). Then retry pip install.** (85% success)
   ```
   Add the SSH private key to the agent: 'ssh-add ~/.ssh/id_ed25519' (or appropriate key file). Then retry pip install.
   ```
2. **Use HTTPS with personal access token: pip install git+https://<token>@github.com/user/private-repo.git** (95% success)
   ```
   Use HTTPS with personal access token: pip install git+https://<token>@github.com/user/private-repo.git
   ```
3. **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://git@github.com/user/private-repo.git'** (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://git@github.com/user/private-repo.git'
   ```

## Dead Ends

- **** — Running 'pip install --upgrade pip' does not affect SSH key authentication; the error is in Git, not pip. (98% fail)
- **** — Setting PIP_REQUIRE_VIRTUALENV has no effect on Git authentication. (99% fail)
- **** — 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% fail)
