Fabian
Fabian

Reputation: 607

How can I prevent git from asking for the passphrase for a ssh signing key when signing commits or tags?

When I sign commits or tags with my ssh key (git commit or git tag -s), git keeps asking for the passphrase of that key. However, I do not want to enter the passphrase for every commit.

I use two different keys for authentication and for signing. Both keys are added to the ssh-agent and I do not have to enter the passphrase for the authentication key. Therefore, the ssh-agent seems to work.

This is my git config:

[user]
    signingkey = C:/Users/<username>/.ssh/id_ed25519_github_signing.pub
[core]
    sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
[gpg]
    format = ssh
[commit]
    gpgSign = true
[tag]
    gpgSign = true

This is my ssh config, which only contains a config for the authentication key:

Host *
    IdentitiesOnly yes

Host github.com
    IdentityFile C:/Users/<username>/.ssh/id_ed25519_github

This is the ssh-add -L output:

ssh-ed25519 <authentication pub key> <username>@mail.com
ssh-ed25519 <signing pub key> <username>@mail.com

I already added the key to the ssh-agent and expected that I do not have to enter the passphrase anymore.

I also tried to use the authentication key for signing commits and then I also have to enter the passphrase for that key.

Could it be that git uses "its own" openssh for signing commits instead of window's openssh, even though I configured the ssh command?

Upvotes: 3

Views: 1210

Answers (1)

Andrew Savinykh
Andrew Savinykh

Reputation: 26329

Could it be that git uses "its own" openssh for signing commits instead of window's openssh, even though I configured the ssh command?

Yes. Use:

git config --global gpg.ssh.program "C:\Program Files\OpenSSH\ssh-keygen.exe"

with the appropriate path, if you want to be using Windows OpenSSH and SSH agent. Do not forget to check that your SSH agent works otherwise (e.g. with regular SSH connections).

Set GIT_SSH environment variable to C:\Program Files\OpenSSH\ssh.exe (or the appropriate path to the executable, depending on your installation method), you will need to restart your shell, after you've done that.

Upvotes: 2

Related Questions