Skip to content

LazyGit fails when using SSH agent without local private key #5125

@kopach

Description

@kopach

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). 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:

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

lazygit --version
commit=, build date=, build source=Homebrew, version=0.57.0, os=darwin, arch=arm64, git version=2.52.0
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions