Skip to content

ssh-tpm-agent: Unable to find private key when using SSH certificate for git commit signing #80

@andsens

Description

@andsens

This git config

$ cat .gitconfig
[user]
  signingKey = /home/aim/.ssh/id_ecdsa.pub

works exactly as expected when using ssh-tpm-agent. However when using certificates for signing commits with

[user]
  signingKey = /home/aim/.ssh/id_ecdsa-cert.pub

the agent fails with

time=2024-12-17T16:27:23.307+01:00 level=DEBUG msg="called list"
time=2024-12-17T16:27:23.307+01:00 level=DEBUG msg="called signwithflags"
time=2024-12-17T16:27:23.307+01:00 level=DEBUG msg="trying to sign as proxy..."
time=2024-12-17T16:27:23.308+01:00 level=INFO msg="agent 13: no private keys match the requested public key"

I'm guessing this part

for _, s := range signers {
if !bytes.Equal(s.PublicKey().Marshal(), key.Marshal()) {
continue
}
return s.(ssh.AlgorithmSigner).SignWithAlgorithm(rand.Reader, data, alg)
needs to look for certificates as well?

If ssh signing is anything like x509 signing you should get the entire tbs/ToBeSigned payload submitted and just sign that as usual. Then git attaches the certificate to the signature, meaning that should be all there is to it. So my guess is the issue simply stems from git not attaching the certificate if you don't specify one as the signingKey. (loads of assumptions here, don't take my word for anything I just said ;-) )

p.s.: I'm bombarding you with new issues right now, sorry about that 😆. Let me know if I can help you with any of the fixes or do some research for you. I'm heading for vacation today but can work on it in the new year.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions