jesseduffield / jesseduffield/lazygit

LazyGit fails when using SSH agent without local private key

Open
#5,125 0 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Describe the bug

LazyGit fails during Git operations (e.g. rebase) when using an SSH agent that holds the private key externally and no local SSH private key file exists. Even though Git CLI works correctly via `SSH_AUTH_SOCK`, LazyGit errors out saying no private key is found.

In my setup, SSH private keys are managed by an authenticator-based SSH agent ([Bitwarden](https://bitwarden.com/help/ssh-agent/)). Only the public key exists locally.

---

### To Reproduce

1. Configure an SSH agent that stores the private key externally (e.g. Bitwarden).
2. Ensure no SSH private key files exist locally (only public keys).
3. Export `SSH_AUTH_SOCK` in the shell (e.g. via `.zshrc`).
4. Verify Git CLI works (`git fetch`, `git push`, etc.).
5. Open LazyGit.
6. Perform a Git operation that requires writing commits (e.g. interactive rebase with squash).

---

### Expected behavior

LazyGit should rely on the SSH agent (via `SSH_AUTH_SOCK`) in the same way Git CLI does and should not require a local SSH private key file to be present.

---

### Actual behavior

LazyGit fails with an error indicating that a private key is missing, even though the SSH agent is correctly configured and Git CLI works.

Example error during rebase:

```sh
Rebasing (2/7)Rebasing (3/7)Rebasing(4/7)Rebasing(5/7)error: No private key found for public key "/Users/***/.ssh/***.pub"?

error: failed to write commit object
hint: Could not execute the todo command
```

### Screenshots

Image

### Version info

```sh
lazygit --version
commit=, build date=, build source=Homebrew, version=0.57.0, os=darwin, arch=arm64, git version=2.52.0
```

```sh
git --version
git version 2.52.0
```

### Additional context
Using external SSH agents without storing private keys on disk is a common and security-recommended workflow. This issue suggests LazyGit may be bypassing Git’s normal SSH handling or invoking SSH in a way that ignores the agent.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.