3.5 KiB
3.5 KiB
title, intro, redirect_from, versions, topics
| title | intro | redirect_from | versions | topics | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Generating a new GPG key | If you don't have an existing GPG key, you can generate a new GPG key to use for signing commits and tags. |
|
|
|
{% data reusables.gpg.supported-gpg-key-algorithms %}
Generating a GPG key
{% note %}
Note: Before generating a new GPG key, make sure you've verified your email address. If you haven't verified your email address, you won't be able to sign commits and tags with GPG.{% ifversion fpt %} For more information, see "Verifying your email address."{% endif %}
{% endnote %}
- Download and install the GPG command line tools for your operating system. We generally recommend installing the latest version for your operating system. {% data reusables.command_line.open_the_multi_os_terminal %}
- Generate a GPG key pair. Since there are multiple versions of GPG, you may need to consult the relevant man page to find the appropriate key generation command. Your key must use RSA.
- If you are on version 2.1.17 or greater, paste the text below to generate a GPG key pair.
$ gpg --full-generate-key - If you are not on version 2.1.17 or greater, the
gpg --full-generate-keycommand doesn't work. Paste the text below and skip to step 6.$ gpg --default-new-key-algo rsa4096 --gen-key
- If you are on version 2.1.17 or greater, paste the text below to generate a GPG key pair.
- At the prompt, specify the kind of key you want, or press
Enterto accept the default. - At the prompt, specify the key size you want, or press
Enterto accept the default. Your key must be at least4096bits. - Enter the length of time the key should be valid. Press
Enterto specify the default selection, indicating that the key doesn't expire. - Verify that your selections are correct.
- Enter your user ID information.
{% note %}
Note: When asked to enter your email address, ensure that you enter the verified email address for your GitHub account. {% data reusables.gpg.private-email %} {% ifversion fpt %} For more information, see "Verifying your email address" and "Setting your commit email address."{% endif %}
{% endnote %}
- Type a secure passphrase. {% data reusables.gpg.list-keys-with-note %} {% data reusables.gpg.copy-gpg-key-id %}
- Paste the text below, substituting in the GPG key ID you'd like to use. In this example, the GPG key ID is
3AA5C34371567BD2:
$ gpg --armor --export <em>3AA5C34371567BD2</em>
# Prints the GPG key ID, in ASCII armor format
- Copy your GPG key, beginning with
-----BEGIN PGP PUBLIC KEY BLOCK-----and ending with-----END PGP PUBLIC KEY BLOCK-----. - Add the GPG key to your GitHub account.