Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify gpg.ssh.allowedSignersFile for ssh key signing #34387

Closed
1 task done
nguyenvulong opened this issue Aug 23, 2024 · 9 comments
Closed
1 task done

Clarify gpg.ssh.allowedSignersFile for ssh key signing #34387

nguyenvulong opened this issue Aug 23, 2024 · 9 comments
Labels
authentication Content relating to authentication content This issue or pull request belongs to the Docs Content team more-information-needed More information is needed to complete review SME reviewed An SME has reviewed this issue/PR stale There is no recent activity on this issue or pull request

Comments

@nguyenvulong
Copy link

nguyenvulong commented Aug 23, 2024

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key?platform=linux#telling-git-about-your-ssh-key

What part(s) of the article would you like to see updated?

Telling Git about your SSH key

I believe it should mention adding

gpg.ssh.allowedsignersfile=/path/to/.config/git/allowed_signers

Otherwise, git would complain that

error: gpg.ssh.allowedSignersFile needs to be configured and exist for ssh signature verification

And in case rules were set, in a project settings > rules > rulesets, github will refuse push

Require signed commits
Commits pushed to matching refs must have verified signatures.
remote: - Commits must have verified signatures.
remote:   Found 1 violation:
remote:
remote:   bd96ff44bfa007357c164fb564b3fdd781b31322
remote:
To github.com:just/a-repo.git
 ! [remote rejected] main -> main (push declined due to repository rule violations)
error: failed to push some refs to 'github.com:just/a-repo.git'

Additional information

Related issue #28577

@nguyenvulong nguyenvulong added the content This issue or pull request belongs to the Docs Content team label Aug 23, 2024
Copy link

welcome bot commented Aug 23, 2024

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Aug 23, 2024
@nguyenalex836 nguyenalex836 added waiting for review Issue/PR is waiting for a writer's review authentication Content relating to authentication and removed triage Do not begin working on this issue until triaged by the team labels Aug 23, 2024
@nguyenalex836
Copy link
Contributor

@nguyenvulong Thank you for opening an issue! I'll get this triaged for review ✨

@subatoi subatoi added the needs SME This proposal needs review from a subject matter expert label Sep 17, 2024
Copy link
Contributor

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert 👀

@nguyenalex836
Copy link
Contributor

@nguyenvulong Thank you for your patience while our SME team reviewed! One of our SMEs wanted to relay the following information -

I'm able to ssh sign and push commits without configuring the gpg.ssh.allowedsignersfile. Looking at the remote commits, they are properly flagged as verified. If I run the local command git log --show-signature to view my commit signatures, without the allowedSignersFile configured I do see the errors that they're describing, but these errors don't block me from pushing, and they don't stop the commits from being verified by GitHub. This is because git itself doesn't have the information that it needs to verify the commits locally but GitHub.com has the public key for verification since it's been uploaded to the user's account settings.

The question here is: does lack of local allowedSignersFile stop a user from pushing if they have branch protection rules requiring verified commits? For me, the answer is no - I was able to push just fine. I'm not sure if this is true across all versions of git, though.

One thing to note, if I delete the SSH key from my GitHub account settings, pushing the commit is blocked even after the commit was locally signed.

After adding an allowedsignersfile configuration for myself, I can now locally see that my commits are signed but still can't push unless the public key is linked to my GitHub account from my account settings. So, allowedsignersfile seems to be specifically and only for local signatures and doesn't block push while branch protections for commit signatures are enabled.

Is there possibly anything specific about your OS or git version that's blocking you from pushing if you don't have an allowedsignersfile? It's fine if git show --show-signature shows errors, since we aren't concerned about local commit signatures verification 💛

@nguyenalex836 nguyenalex836 added more-information-needed More information is needed to complete review SME reviewed An SME has reviewed this issue/PR and removed waiting for review Issue/PR is waiting for a writer's review needs SME This proposal needs review from a subject matter expert labels Sep 24, 2024
@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Oct 8, 2024
Copy link
Contributor

github-actions bot commented Oct 8, 2024

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. See this blog post on bug reports and the importance of repro steps for more information about the kind of information that may be helpful.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
@bric3
Copy link

bric3 commented Jan 20, 2025

For the sake of completeness, I had in my git alias a git log format that was using %G?.

And I started to see these error: gpg.ssh.allowedSignersFile needs to be configured and exist for ssh signature verification messages, it happened because of the contributor started to use ssh to sign commits.

I also believe that for completeness, this should be at least mentioned as a side effect in the doc.


I worked around it with (of course this file being empty, the signature is not known whether it's valid or not (status U))

$ touch ~/.ssh/empty-allowedSignersFile
$ git config --global gpg.ssh.allowedSignersFile ~/.ssh/empty-allowedSignersFile

@nguyenalex836
Copy link
Contributor

@bric3 Thank you for sharing input on this! ✨

I also believe that for completeness, this should be at least mentioned as a side effect in the doc.

Given the age of this issue, would you be willing to open a new one in this repo that also includes what you would propose adding to highlight this side effect? 💛

@TimRudy
Copy link

TimRudy commented Jan 31, 2025

Hi, I would participate by opening an issue with description, but I'm just a newbie who came across this.

Using these pages:
   managing-commit-signature-verification/signing-commits
   managing-commit-signature-verification/telling-git-about-your-signing-key

I didn't seem to have a signed commit - i.e. "No signature"!!! below.
I failed to notice the error at the top. (The red hilight is why my attention was not drawn to it, at all - numerous times.)
Subsequently when I did the touch and empty-allowedSignersFile trick above, I get the more honest message, second example below.

I show second example with the commit I did locally, and next commit is remote commit.

  1. "No principal matched." is not too great. I hope not to see that.
  2. "gpg: Can't check signature: No public key" for the commit in remote which is perfectly valid and it's signed. You guys sure that key-signing is a nice system? I need to go to GitHub to see "Verified" etc., OK. But maybe the "Can't check signature" message should go away, or should turn it into something more informational with a URL, for good user experience.
  3. But obviously my main complaint is:
    a. As a first time commit-signer, I want reassurance locally that it worked, I shouldn't need to push to find out.
    b. The docs didn't mention gpg.ssh.allowedSignersFile and I need to go Google that now.

$ git log --show-signature
error: gpg.ssh.allowedSignersFile needs to be configured and exist for ssh signature verification
commit 87001e69 (HEAD -> PR863)
No signature                                               <-- red hilight
Author: TimRudy <[email protected]>
Date:   Thu Jan 30 17:31:16 2025 -0500


$ git log --show-signature
commit 87001e69 (HEAD -> PR863)
Good "git" signature with ED25519 key SHA256:jE7AwT...    <-- red hilight
No principal matched.                                     <--
Author: TimRudy <[email protected]>
Date:   Thu Jan 30 17:31:16 2025 -0500

    Fix launch task for Windows

commit 2886ebad (upstream/develop, upstream/HEAD, origin/develop, origin/HEAD, develop)
gpg: Signature made Thu Jan 30 12:34:08 2025 EST          <-- red hilight
gpg:                using RSA key F620B4                  <--
gpg: Can't check signature: No public key                 <--
Merge: 8ea95e65 b3b2f6c4
Author: Rst <[email protected]>
Date:   Thu Jan 30 06:51:27 2025 +0100

@Noeurn1
Copy link

Noeurn1 commented Jan 31, 2025

Believers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication Content relating to authentication content This issue or pull request belongs to the Docs Content team more-information-needed More information is needed to complete review SME reviewed An SME has reviewed this issue/PR stale There is no recent activity on this issue or pull request
Projects
None yet
Development

No branches or pull requests

8 participants
@bric3 @nguyenvulong @TimRudy @subatoi @nguyenalex836 @Noeurn1 and others