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

Add support for signing commits with GPG #5065

Closed
kripod opened this issue Apr 7, 2016 · 37 comments · Fixed by #27136
Closed

Add support for signing commits with GPG #5065

kripod opened this issue Apr 7, 2016 · 37 comments · Fixed by #27136
Labels
feature-request Request for new features or functionality git GIT issues help wanted Issues identified as good community contribution opportunities verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@kripod
Copy link

kripod commented Apr 7, 2016

VS Code should optionally be able to sign git commits with a given GPG key, as it is a good practice for authorization nowadays.

@Tyriar
Copy link
Member

Tyriar commented Apr 7, 2016

Doesn't GitHub's authentication basically do the same thing, since you need to auth with GitHub to push to repos you have access to?

@Tyriar Tyriar self-assigned this Apr 7, 2016
@Tyriar Tyriar added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Apr 7, 2016
@kripod
Copy link
Author

kripod commented Apr 7, 2016

GitHub auth is NOT related to GPG-signed commits if I know right.

@kripod
Copy link
Author

kripod commented Apr 7, 2016

Basically, I would like built-in functionality for appending the -S command line argument to git commit, as shown here.

@Tyriar
Copy link
Member

Tyriar commented Apr 7, 2016

Sure, but isn't what it's accomplishing done by GitHub account/email linking? You need to link your email to an account and need credentials to the account to push.

@kripod
Copy link
Author

kripod commented Apr 7, 2016

GPG can be used in any git environment (for instance: GitLab, BitBucket, etc.)

I though this could be actual after seeing the blog post of GitHub about verifying commits.

@Tyriar
Copy link
Member

Tyriar commented Apr 7, 2016

@joaomoreno thoughts?

@Tyriar Tyriar assigned joaomoreno and unassigned Tyriar Apr 7, 2016
@joaomoreno
Copy link
Member

I'd argue that for any given repo, you'd either want to sign all commits or none. Based on that, I suggest to use the commit.gpgsign = true git configuration in your repo, available since 2.0, which will make git sign all commits by default.

Does that work for you @kripod?

@kripod
Copy link
Author

kripod commented Apr 8, 2016

I use exactly that, but when I try to commit from VS Code with that config attribute set, I get the following error output in the Git console of Code:

git fetch
git show HEAD:src/relation.js
git show HEAD:src/relation.js
git add -A -- .
git commit --quiet --allow-empty-message --file - --all
gpg: WARNING: unsafe permissions on homedir `C:\Users\user\AppData\Roaming\gnupg'
gpg: cannot open tty `no tty': No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
git config --get-all user.name
git config --get-all user.email
git show HEAD:src/relation.js

@Tyriar
Copy link
Member

Tyriar commented Apr 8, 2016

I misread the issue, I thought you were talking about the vscode repo starting to sign commits, not adding the feature.

@joaomoreno while looking into signing commits yesterday, this I came across this http://stackoverflow.com/a/10166916/1156119

Signing each commit is totally stupid. It just means that you automate it, and you make the signature worth less. It also doesn't add any real value, since the way the git DAG-chain of SHA1's work, you only ever need one signature to make all the commits reachable from that one be effectively covered by that one. So signing each commit is simply missing the point.

@0x0ade
Copy link

0x0ade commented Apr 10, 2016

@kripod Not just vscode is affected: Bazaar Launchpad bug #847388

If you're using an agent: As a workaround (a configuration change affecting not just vscode) it's possible to add no-tty to your gpg.conf. For example, run

echo 'no-tty' >> ~/.gnupg/gpg.conf

Snippet from gnupg docs explaining --no-tty:

--no-tty
Make sure that the TTY (terminal) is never used for any output. This option is needed in some cases because GnuPG sometimes prints warnings to the TTY even if --batch is used.

From what I've noticed, gpg is now less verbose (doesn't remind me that I "need my passphrase" on git commit; is completely silent on gpg -s). I don't know what else this affects and thus I feel bad for suggesting this, but it works.

If you're not using an agent: Again referring to Launchpad, this time the bzr (Bazaar) package, you seem to be out of luck.

@joaomoreno
Copy link
Member

Thanks for that @0x0ade. Does it solve it for you, @kripod?

@kripod
Copy link
Author

kripod commented Apr 11, 2016

Well, having listened to @Tyriar, I'm not signing my commits anymore, but thank you for all the help provided!

@adamvoss
Copy link

This article does a good job of explaining the impact of differences and advantages of different signing policies.

It is not strictly accurate that signing each commit is "totally stupid."

@dmportella
Copy link
Contributor

it would be nice if vscode gave me the opportunity to sign a commit.

@cpjolicoeur
Copy link

cpjolicoeur commented Apr 17, 2017

Signing commits is not "totally stupid" and, in fact, has very real security implications. Not all Git code happens to be "pushed" to Github or BitBucket. Many places use git internally for all sorts of things and git commit signing is a very needed feature and often a requirement.

I am using a gpg-agent and still am unable to sign commits in VSCode, for what it's worth.

@joaomoreno joaomoreno reopened this Apr 18, 2017
@joaomoreno joaomoreno added feature-request Request for new features or functionality and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Apr 18, 2017
@joaomoreno joaomoreno added this to the Backlog milestone Apr 18, 2017
@joaomoreno joaomoreno removed their assignment Apr 18, 2017
@joaomoreno joaomoreno added the git GIT issues label Apr 18, 2017
@Marqin
Copy link

Marqin commented Apr 24, 2017

^ seems that git support is divided into two parts - one is git workbench that's in core and second is git extension (that's built-in?)

Is there any progress on this?

@dmportella
Copy link
Contributor

i dont there is any work going on yet.
I will pick this up but not until this weekend

@dmportella
Copy link
Contributor

I like to confirm I am starting work on this. I will a pull request with a WIP title to show progress soon

@LaurentTreguier
Copy link

Hello here, I recently tried committing with commit.gpgsign set to true. However the issue I encountered is related to my name: it contains an accented 'e' (é) and right now VSCode seems to have some encoding problem (at least with git):
image
Which prevents git from detecting the correct GPG key.

@pradyunsg
Copy link

@dmportella Hi! Any progress updates? :)

@dmportella
Copy link
Contributor

got all the changes needed mapped now going to add menus items etc
should be done soon just lots of test and things to write

@dmportella
Copy link
Contributor

I have the change almost complete just tidying up and getting ready to commit.

@dmportella
Copy link
Contributor

Pull request #27136
Added support to GPG signing hope all is oke

@jens1o
Copy link
Contributor

jens1o commented May 28, 2017

would love to see this.

@dmportella
Copy link
Contributor

dmportella commented Jun 27, 2017

Me too, it was added to the June milestone that got me excited but now its back in the backlog.... So I don't know whats going on.

The pull request is this one: #27136

@rawkode
Copy link

rawkode commented Jul 18, 2017

@Tyriar Please, that comment, which is purely subjective, is very old and it's quoting achieves nothing, but FUD.

Impersonating authors on GitHub is easily done and signing ALL commits is good practice. Especially with hardware tokens, such as Yubikeys.

I mean no harm with 30912, I am merely showing how easy it is to submit a commit by another. I feel GitHub could do more here too.

On the main page, images are small and easily distracted (I could even change mine, I guess ... and my name). But the "Verified" means we've signed that commit. I believe it's important, as others seem to have commented also.

verifeid

@dmportella
Copy link
Contributor

I verify ALL my commit is important and we do use yubikeys here at my organisation

@nilbot
Copy link

nilbot commented Jul 31, 2017

@Tyriar GPG signing provides authentication on the commits themselves. What you said in #5065 (comment) and subsequent comments are irrelevant to the issue. Because without signing the commit, I can easily fake you as the author and submit a fraudulent patch (e.g. intentionally infringing copyright of your rival company) via other channels (e.g. email) to another committer, who will be having a hard time to know whether you actually wrote the patch or not. And if that committer push the CL to GitHub, GitHub will happily link that to your account.

See this commit for example:
jayphelps/git-blame-someone-else@e5cfe4b

@Tyriar
Copy link
Member

Tyriar commented Jul 31, 2017

Hi all, no need to try to convince me anymore 😄

@jens1o
Copy link
Contributor

jens1o commented Aug 14, 2017

YEAHHHHH!

🎉 🎉 🎉 🎉

@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Aug 30, 2017
@roblourens roblourens added the verified Verification succeeded label Sep 1, 2017
@dawidp
Copy link

dawidp commented Sep 26, 2017

This error

git commit --quiet --allow-empty-message --file - --all
git show :hinode/models/base.py
gpg: cannot open tty `no tty': No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object

can be cause by password protected gpg key.

@dmportella
Copy link
Contributor

something related to the error you seen: isaacs/github#675

@JeremyLoy
Copy link
Contributor

JeremyLoy commented Oct 17, 2017

I got it to work for me, but only after signing a previous commit (~5 minutes prior) manually through the integrated terminal.

I have a hunch that the root cause of the error message gpg failed to sign the data, is that VS Code is requesting to open the prompt, and failing to do so.

If you already entered your password via prompt previously, VS Code signs the commits perfectly fine.

@pradyunsg
Copy link

pradyunsg commented Oct 17, 2017 via email

@dmportella
Copy link
Contributor

usually you see this problem when you dont things set up properly for gpg signing. that has been my experience

@DrSensor
Copy link

DrSensor commented Nov 7, 2017

In Linux, I solve /dev/tty problem by adding binary exec of gpg2 path to git global config
git config --global gpg.program $(which gpg2)

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality git GIT issues help wanted Issues identified as good community contribution opportunities verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.