sourcegit-scm / sourcegit

Windows/macOS/Linux GUI client for GIT users
MIT License
1.24k stars 122 forks source link

Need to enter passphrase on every command #586

Open spetroll opened 4 days ago

spetroll commented 4 days ago

Hi,

I use ssh keys to authenticate and I noticed that I need to enter my passphrase on every command. The command then works, but it's getting a bit annoying.

While trying to debug the issue with my limited knowledge, I observered a different behaviour depending on how I open sourcegit. When I open sourcegit from my zsh shell, it works as expected. But when I open sourcegit from the gnome dash (which I added by using "Pin to dash"), the mentioned problem occurs.

OS: Arch Linux Gnome: 47.0 sourcegit: 8.35 git: 2.47 zsh: 5.9 terminal: alacritty 0.13.2

Happy to provide further information if needed.

aikawayataro commented 4 days ago

When I open sourcegit from my zsh shell, it works as expected.

How do you start ssh-agent? Judging from what you said, it looks like you start it in your .zshrc.

See also https://wiki.archlinux.org/title/GNOME/Keyring#SSH_keys on how to setup GNOME keyring ssh-agent wrapper

love-linger commented 4 days ago

Or have you define the GIT_SSH_COMMAND in your zsh?

love-linger commented 4 days ago

SourceGit will check if the GIT_SSH_COMMAND has been defined already. If it is not available, SourceGit will use ssh -i $SSH_PRIVATE_KEY instead. See the code:

// If an SSH private key was provided, sets the environment.
if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey))
    start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}'");