-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
Sign a commit if ssh secret key is provided #2047
Conversation
based on your last comment in the previous PR:
still cannot follow what you refer to here. gitui now only depends on syn2, there is no old syn1 in the dependencies anymore. what I am asking is: what is needed to make CI not fail?
I think we have some misunderstanding here. I am not saying lets introduce a bespoke env var that is gitui specific instead of a cli arg. My question is: how do other tools get fed the SSH key/pwd? Primarily the regular git cli and why can't we use the same way? |
https://github.com/extrawurst/gitui/actions/runs/7794027383/job/21254692240
If the cli is good, I will pick these back and drop the The best practice for using an ssh password is to ask interactively with UI, such that the user can avoid writing down the password in a file or env. And the default ssh key will be |
Ok lets make things easy then and scan for the default keys, no arg or env for now. also if we know we shall encrypt via ssh and we find a default key do we know if that key requires a pwd? so that we can fail for the MVP in that case because we don't know the pwd |
@yanganto but mostly we need to get the CI green |
You misunderstand the mechanism. The commit can be signed with any ssh secret key, but only one. Github will use verify the commit only if the corresponding pub key is already set in Github by user. So we can not scan all the ssh key to select some one who is valid, because all key are valid and possible in use. The default key path will be different because user can use different kinds of crypto mechanism. We can have a default value as now, but we need a interface let user change it easier.
No, if we do not have a password, we still can sign the commit but it will not verified by GITHUB, because the bytes will not be different from a real one. |
then lets go back to square one: how does it work with the git-cli, how does it get configured and why cant we use the same method? |
as far as i can see it has to be configured like this: https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key#telling-git-about-your-ssh-key so we can just use these git configs to know what signing key to use and whether signing is supposed to happen: so lets use that |
git commit use following option to sign a commit with GPG And the ssh sign is using ssh secret key but the header still There is not exactly an interface in git-cli for the ssh key. The way we are using now is |
You can see the config is a pub key for verification not a secret key for a sign. Do we have an assumption that there is a secret key and the key is the pub key path remove |
By the way, the way to set git config with
So I think nobody write config in that way for now |
You may wonder why we need |
@extrawurst It now is ready to review |
this is exactly what every source I find about ssh-commit-signing tells you to do. to sign with your public key. what am I missing? but don't take my word for it, see Gitlab docs, tower (slightly popular git GUI app) and this high ranking blog post here |
A good sign mechanism is to use a secret key and pass the public key to verify whether it is true or not. If you sign with a public key, then you need to pass the secret key to Github for verification. 🙄 The blog post here is signed with a secret key, but he put the content of key in the The ssh setting will need a git after Does current gitui handle a global git config and overlayed with a local git config? I don't think the first iteration needs to handle these variations. |
It literally says in the link above
Fine with me. Lets use
yes |
What is the thing in your |
in my
Is there anything I should check for you? |
What is the content of |
I'm fairly certain vscode nor any jetbrains product needs it in order to sign a commit. |
Is the sign an ssh sign or gpg sign?
We don't need |
I am using ssh signing |
What is the content of |
I guess the contents of the allowed_signers is not relevant to this issue, as I show in the screenshot: when the signature is created by the git CLI, it works as expected, and the commit is properly shown as signed. |
The important problem is if set up correctly, we can see the verified tag on the GITHUB web page. Did the commit( If the Did this PR correctly sign and show verified when you gave your public key to GITHUB? |
I'm glad to see the work done so far! Just wanted to add a datapoint. Compiled from this commit: yanganto@43bea21, I ran Seems like it works fine? |
If you do not put the SSH key setting in the git config, there is no alert and no sign. If you put the ssh_key settings in the git config (no allowedSignersFile), you can sign without an alert. If you put the pub key to GITHUB, you can get a verified tag, else you will get an unverified tag. If you put the allowedSignersFile and the public key to the file, you can check the sign locally without an alert. If you want something you need to provide the correct setting for the tool. It is reasonable. |
Update: it still does not work for my use-case Git CLI:
With GitUI (compiled with
The the two tests have been run in the same folder, with no changes to any git configuration file About the |
Are these settings in your gitconfig?
Can you also provide this? Do you put your pub key on GITHUB? Aggreed, the |
Yes, those are the settings I have:
As mentioned above: I tested both cases from the same folder ( Notes:
|
yes, as you can see from https://github.com/thePanz/gitui-test/commits/master/, the commit I did with the git CLI is verified |
Is there a key pair If not. In the change log, I already mentioned the keys are on disk, if not gitui did not sign but no error happened and no alert. This is good behavior you want to see, right? |
No, there is no I guess we spotted the issue then 👍 I believe that a message or warning should be shown in that case, as the git configuration is explicitly asking to add the signature, while gitui is ignoring the missing private key needed to sign it, and thus not respect the configuration. This is not 100% clear from the changelog IMO |
So now you are asking for an alert box with a warning message for this first implementation. Or, another solution is. |
@yanganto I am not asking to do it, I am suggesting to have such behavior as it would help the users to better understand why the signing is required in the git config file, but gitui is adding the commit without the signature (thus ignoring the git config setting) just my 2 cents |
So you want me to refuse commit when gitui can not sign. |
@thePanz I don't see any blocker at this moment. Now anything gitconfig set but gitui cannot do will block which follows the current behavior of master branch. If you agree with my point and try to warn the user not to block the user you can open an issue and mention these #2047 (comment) #2047 (comment). These are already clear enough to solve in other PRs but not this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update to latest master and integrate with the new signing trait
closed via #2175 |
This Pull Request fixes #1149
It changes the following:
user.signingKey
of gitconfig will be used to sign the commitI followed the checklist:
make check
without errors