Adding a GPG key to your account
What is a GPG key?
GPG stands for GNU Privacy Guard, which is an open-source cryptographic software program and uses an implementation of the Open PGP standard. A GPG key is used to sign each commit you make so your collaborators can be sure it was you who made it.
Adding an Existing GPG key
If you have your public key in an easy to find location, great! You can skip to adding it to your account. If not we will be using the GnuPG software to check, if you have downloaded this before you can skip to Generating a GPG key.
- Download and install GnuPG.
If you are using a Linux distro this might already be installed, check by typing
gpg --versionin the terminal.
gpg --list-secret-keys --keyid-format LONGinto your terminal, it will list all the keys that you have both a public and private key for.
- Check the output for a key that you want, if there are none, or none that you want to use, continue to Generating a GPG key. If there is one that you want to use, skip to adding it to your account.
Be sure that your selected key uses the same email as your Codeberg account.
Generating a GPG keyIf you haven’t already, be sure to [install](https://gnupg.org/download/index.html#binary) GnuPG, as you will be using it to generate your keys.
gpg --full-generate-keyinto your terminal
1and press enter to select
RSA and RSA
- Enter your desired key size, we recommend 4096 bits, press enter to confirm
- Choose the amount of time you want it to be valid for, we recommend 1-2 years for increased security, however you can type 0 for it to never expire. Press enter to confirm.
- Verify your selections are correct, type
yand press enter to confirm
- Enter your information, be sure to use the same email as your Codeberg account
- Type in a passphrase, make sure you write it down somewhere safe. You'll need it later to add your key to Git or revoke it if it is compromised
Adding your GPG key to Codeberg
gpg --list-secret-keys --keyid-format LONGinto the terminal
- Select the key you would like to use (the one you just generated). In this example, the GPG key ID is
$ gpg --list-secret-keys --keyid-format LONG
sec rsa4096/3AA5C34371567BD2 2021-06-06 [SC] [expires: 2022-06-06]
uid [ultimate] knut <firstname.lastname@example.org>
ssb rsa4096/42B317FD4BA89E7A 2021-06-06 [E] [expires: 2022-06-06]
gpg --armor --export <GPG KEY ID>into the terminal
- Copy the output including the
-----BEGIN PGP PUBLIC KEY BLOCK-----and
-----END PGP PUBLIC KEY BLOCK-----
- Go to the SSH/GPG Keys tab in your Codeberg settings.
Add Keyin the
Manage GPG Keyssection, paste in your public key and click the
Telling Git about your GPG keyIn order for you to use your key you will also need to tell Git about it.
- Open your terminal
git config --global user.signingkey <GPG KEY ID>
This guide is derived from GitHub Docs, used under CC-BY 4.0.
Hey there! 👋 Thank you for reading this article!
Is there something missing or do you have an idea on how to improve the documentation? Do you want to write your own article?
For an introduction on contributing to Codeberg Documentation, please have a look at the Contributor FAQ.
© Codeberg Docs Contributors. See LICENSE