GPG signing plays a critical security role in ensuring the authenticity and integrity of the debian packages. Every debian repository is signed with a private GPG key by the maintainer, and your system needs the matching public key to verify the signature.
This article will guide you to configure GPG keys with the Artifactory debian repositories.
Artifactory and Debian remote repositories
When packages are downloaded via a remote Debian repository in Artifactory, signed metadata from the upstream source (e.g., InRelease, Release.gpg) is pulled into the local cache. If the corresponding GPG public key from the upstream is present on the APT client, signature verification succeeds and no error is shown. However, if those keys are not present, , you may encounter errors like:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <keyid>
One option is to to import the GPG key of the upstream repository to the Apt client. This process requires having access to the public GPG keys that are used to sign the repository metadata.
For example:
gpg --keyserver keyserver.ubuntu.com --recv-keys <keyid>
gpg --armor --export <keyid> | sudo apt-key add -
Note:
The keyserver depends on which keyserver the GPG key is published.
Another option and the recommended solution is to add these remote repositories to the Virtual repositories and enable GPG key signing.
Artifactory Debian Virtual repositories and GPG Key Signing
Artifactory aggregates metadata from all included local and remote repositories and regenerates new metadata for the virtual repo. If no GPG key is assigned to the virtual repository, this generated metadata remains unsigned, leading to the “not signed” error during apt update.
The repository ... is not signed
One temporary workaround is to suppress the error using: [trusted=yes]in the APT source entry.
Ex:
deb [trusted=yes] https://ARTIFACTORY_HOST/artifactory/debian-virtual bionic main
While this bypasses signature verification, it is not a recommended practice, especially in production environments. In some cases, you may not encounter this error if the APT client is using cached metadata. However, once the cache expires or the metadata is refreshed, the error will reappear.
Configuring GPG Signing
To permanently resolve this issue, configure a GPG key for the virtual Debian repository. Even if it aggregates multiple local or remote repositories, only one GPG key is needed to sign its metadata. The same key can also be reused across other Debian virtual repositories.
These steps are also applicable if you want to associate a GPG key with a Debian local repository.
Steps to Generate a GPG Key Pair
On a secure machine, generate a key :
gpg --full-generate-key
gpg --list-keys
Note:
You can select the RSA and RSA (1st option)
Export the keys:
gpg --output debian-private.key --armor --export-secret-keys "you@example.com"
gpg --output debian-public.key --armor --export "you@example.com"
Upload the Keys and Assign the GPG Key to a local/Virtual Repository
Upload the key via Artifactory UI: Go to Administration > Security > Keys MAnagement > Signing Keys and upload the key under GPG Signing Keys by selecting Add keys > GPG Keys
To assign a key to your Debian virtual repository:
- Go to Administration > Repositories
Edit the relevant virtual Debian repository
- Under the GPG Key Pair section, select your key from the Primary key name dropdown
Save the configuration
This will enable automatic signing of the Release metadata during reindexing.
Note:
The reindexing will be triggered only when a deployment happens. If you want to verify the GPG key immediately, please ensure to perform a reindex on the virtual repository. ( UI → Application → Artifacts → <reponame> → Recalculate Index)
REST API: Calculate Debian Repository Metadata
Distributing the Public GPG Key to Apt Clients
Once a GPG key is configured in Artifactory, the APT clients must trust the corresponding public key to avoid signature verification errors. Use the following command to download and install the public key on Debian clients:
To add the key to the Debian machine:
curl -u<username>:<password> https://ARTIFACTORY_HOST/artifactory/api/security/keypair/public/repositories/<debian-repo-name> | gpg --dearmor -o /usr/share/keyrings/arti-debian-keyring.gpg
Reference the key in the APT source:
deb [signed-by=/usr/share/keyrings/arti-debian-keyring.gpg] https://ARTIFACTORY_HOST/artifactory/debian-virtual bionic main
Example configurations
Before testing any configuration in the apt client, please make sure to clean the cache using “apt clean all” to get the correct results.
1. Apt client configuration, without adding GPG key
sources.list:
deb https://myartifactory.vm/artifactory/jf-debian bionic main
auth.conf:
machine https://myartifactory.vm
login <username>
password <password>
Note: Credentials are added to auth.conf. Here, “jf-debian” is a debian virtual repository.
# apt update
Ign:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
Get:2 https://myartifactory.vm/artifactory/jf-debian bionic Release [1869 B]
Ign:3 https://myartifactory.vm/artifactory/jf-debian bionic Release.gpg
Reading package lists... Done
E: The repository 'https://myartifactory.vm/artifactory/jf-debian bionic Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
2. Apt client configuration, with [Trusted=yes]
sources.list:
deb [trusted=yes] https://myartifactory.vm/artifactory/jf-debian bionic main
# apt update
Ign:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
Get:2 https://myartifactory.vm/artifactory/jf-debian bionic Release [1869 B]
Ign:3 https://myartifactory.vm/artifactory/jf-debian bionic Release.gpg
Get:4 https://myartifactory.vm/artifactory/jf-debian bionic/main amd64 Packages [1046 kB]
Fetched 1048 kB in 1s (1835 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
3. Apt client configuration with GPG Key
Error1:
Once the GPG key is assigned to the virtual repository, metadata will be signed only if the virtual repository is reindexed. If the virtual repository is not yet reindexed, and has other remote repositories included, then the apt client will be able to find some signed metadata there, and it will show an error if those public keys are not available in your apt client.
# apt update
Get:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease [21.5 kB]
Err:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8872ED2718602E9E NO_PUBKEY F5DA5F09C3173AA6
Reading package lists... Done
W: GPG error: https://myartifactory.vm/artifactory/jf-debian bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8872ED2718602E9E NO_PUBKEY F5DA5F09C3173AA6
E: The repository 'https://myartifactory.vm/artifactory/jf-debian bionic InRelease' is not signed.
Note:
You will receive similar errors, if you configure an Artifactory remote repository directly in the apt client and the GPG public keys of the upstream are not known to the apt client.
Error2:
To resolve the above issues, manually reindex the virtual repository metadata. Once it is reindexed, the debian metadata will be signed with the assigned key. Hence, if we do not download the public key to the apt client, it will show an error.
# apt update
Hit:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
Err:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E95FBFA3D259D88A
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://myartifactory.vm/artifactory/jf-debian bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E95FBFA3D259D88A
W: Failed to fetch https://myartifactory.vm/artifactory/jf-debian/dists/bionic/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E95FBFA3D259D88A
W: Some index files failed to download. They have been ignored, or old ones used instead.
Please note that you will not see a “Repository .. is not signed” error. However, you will see an error for the missing key.
Recommended solution:
Now, to get the GPG signing working properly, and get rid of all the errors, once the repository is reindexed, download the respective GPG key and add it to keyrings. Then configure the key with the debian repository in the sources.list configuration.
curl -s -u<username>:<password> https://myartifactory.vm/artifactory/api/security/keypair/public/repositories/jf-debian| gpg --dearmor -o /usr/share/keyrings/arti-debian-keyring.gpg
sources.list:
deb [signed-by=/usr/share/keyrings/arti-debian-keyring.gpg] https://myartifactory.vm/artifactory/jf-debian bionic main
# apt update
Hit:1 https://myartifactory.vm/artifactory/jf-debian bionic InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Handling Key Rotation and Expiration
Extending Key Expiration
If you have access to the original private key, you can extend its expiration using GPG and re-upload it to Artifactory. Because the key ID remains the same, no changes are needed on the apt client.
Replacing with a New Key
If you're rotating to a new GPG key:
- Upload the new key and set it as the primary key in Artifactory
- Distribute the new public key to all APT clients
- Update the keyring used in the APT source
- Reindex the repository so metadata is re-signed
To calculate metadata or reindex the repo:
UI → Application → Artifacts → <reponame> → Recalculate Index
REST API: Calculate Debian Repository Metadata
Note:
Failure to update the APT clients with the new public key will result in the error: “The following signatures couldn't be verified”.
Using Multiple GPG Keys: Primary and Secondary
Artifactory allows you to configure a secondary GPG key alongside the primary key. This secondary key acts as a backup and is not used unless the primary key is removed or becomes invalid.
If the primary key is deleted, the secondary key is automatically promoted and used for signing. This enables seamless key rotation without disrupting package delivery.
However, make sure that the public key of both primary and secondary keys are installed on the Debian clients. Otherwise, signature verification will fail when the secondary key becomes active.
After changing the active signing key, always reindex the repository:
- Distribute the new public key to all APT clients
- Reindex the repository so metadata is re-signed
Whether the GPG key affects the debian repository migration?
Based on our Artifactory documentation, Artifactory will not be signing the packages, instead it will sign only the Metadata. Hence, if you do not have the old GPG Key pair with you after an Artifactory migration, it will still work. You can generate a new GPG key pair and use it with your Debian repositories.
Reference:
Manage GPG keys for remote repositories
Generate GPG Keys