GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Commit Signing Commit Signing
Giuseppe Cianci edited this page
This guide will show you how you can configure your development setup to automatically sign git commits using GPG and link your GPG key with GitHub. Commit signing with GPG proves your commits are actually from you and haven't been messed with—anyone can fake a Git author name, but they can't fake your cryptographic signature. The catch is that your private key is everything: if someone gets it, they can sign commits as you and potentially slip malicious code into your projects while looking completely legitimate. Keep your GPG key secure with a strong passphrase and treat it like any other critical credential, because once it's compromised, your entire signing credibility goes with it. Make sure you follow the Prerequisites, How To Contribute (microsoft/vscode) guide.
Install the necessary tools and configure GPG: First, install Homebrew (https://brew.sh/). Then run the following commands: brew install gpg2 gnupg pinentry-mac mkdir -p ~/.gnupg echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf echo "use-agent" >> ~/.gnupg/gpg.conf echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile # replace with ~/.zprofile if using ZSH Restart your machine. Yes, really. There are two options: generate or copy an existing key.
Run: With the following options:
In the following example, $ gpg --list-secret-keys --keyid-format LONG
gpg: checking the trustdb
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
/home/joao/.gnupg/pubring.kbx
-----------------------------
sec rsa4096/DF536B632D7967F9 2021-04-07 [SC]
1D0FC7C0350BB570143C934FDF536B632D7967F9
uid [ultimate] Joao Moreno (Key for signing commits for Microsoft) <[email protected]>
ssb rsa4096/41FC60C87D442095 2021-04-07 [E]You can use your key ID to get your public key: $ gpg --armor --export DF536B632D7967F9 -----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK----- Alternatively, you can export a existing key from another machine, by replacing Then, copy it into your machine and import it: Finally, set its trust level to $ gpg --edit-key KEYID gpg> trust Your decision? 5 Follow the Adding a new GPG key to your GitHub account guide to give GitHub your public key. Run the following, replacing Git will now sign all commits by default. Signing requires access to your GPG key, which requires the passphrase. Follow the respective platform specific steps below to decrease pain. Create a dummy commit on a sample local repository. You should see a prompt for your key's passphrase:
Enter your GPG key passphrase and hit OK. In order to avoid typing the passphrase on every commit, you can make GPG remember it for 8 hours or until the next reboot:
Create a dummy commit on a sample local repository. You should see a prompt for your key's passphrase:
In order to avoid typing the passphrase on every commit, just select Create a dummy commit on a sample local repository. You should see a prompt for your key's passphrase:
Enter your GPG key passphrase and hit OK. In order to avoid typing the passphrase on every commit, you can make GPG remember it for 8 hours or until the next reboot:
Make sure that if you push a signed commit to GitHub it appears as
You should guard this key as well as you guard your SSH key. While an SSH key can easily be replaced by another, since it only affects the login to Github, a GPG key will forever be associated with your commits. This means that as soon as you remove the GPG key from GitHub, because say you replaced it with another, the commits won't appear One of the best ways to store a backup or even to use the key directly is to use a YubiKey. You can store a copy of your key in a YubiKey, serving as a backup. Or you can even store the only copy of your key in it and always require your YubiKey when creating commits. This definitely increases security but with the obvious added inconvenience of always needing your YubiKey around when committing changes changes. Learn more. Codespaces will use a different GPG key, but it will indeed sign all your commits automatically, so they appear as verified on GitHub. Learn more. Project Management
Contributing
Documentation Clone this wiki locally |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |