RPM packages in Artifact Central

  • Tier: Premium, Ultimate
  • Offering: GitLab.com
  • Status: Beta

RPM repositories are available only in namespaces where the registry has RPM enabled. Until then, every RPM route in the namespace returns 404 Not Found, the same answer an unknown namespace returns.

An RPM repository in Artifact Central stores RPM packages and serves the signed repodata/ index that dnf reads. The registry signs the index, not the packages in it. RPM is available for hosted repositories only.

Supported clients

ClientSupport
dnfRHEL 8, 9, and 10, and compatible distributions. Works with the configuration on this page.
dnf5Current Fedora. Needs a key import by hand. For more information, see Import the key with dnf5.
microdnfRHEL 8. Cannot read a dnf variable file. For more information, see Hosts that cannot read the variable file.
curlAny host. Publishes packages.

RHEL 7 yum and zypper are not tested.

The curl commands on this page that call the registry use --fail-with-body, which needs curl 7.76 or later. RHEL 8 ships curl 7.61, so on RHEL 8 use --fail instead. --fail does not print the error body.

Authenticate

RPM clients use basic authentication. The registry reads the token from the password field and ignores the username, so a token sent as the username is not a credential and the request fails. A request with no credential or an invalid one returns 401 Unauthorized with a WWW-Authenticate: Basic realm="artifact-registry" header.

The registry does not accept a personal access token or CI/CD job token directly, and it does not accept deploy tokens at all. Exchange a supported token for a registry token first. For more information, see Authenticate with Artifact Central.

The examples on this page read a registry token from the ARTIFACT_REGISTRY_TOKEN environment variable:

shell
export ARTIFACT_REGISTRY_TOKEN="$(glab artifact-registry get-token)"

Create a signing key

An RPM repository signs its metadata with a key from its namespace. Create the key before the first RPM repository. A repository that names no key uses the namespace default key. You cannot create an RPM repository in a namespace that has no RPM key.

Prerequisites:

  • The Artifact Admin role for the organization.
  • A registry token.

To create a key:

shell
curl --fail-with-body --request POST \
  --header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"name": "rpm-internal", "algorithm": "rsa3072"}' \
  "https://<registry_host>/api/v1/<registry_handle>/rpm/signing_keys"

The response carries the key’s fingerprint, 40 uppercase hexadecimal characters. Record it and pass it to whoever configures a host. A host trusts the first key it imports, and nothing the registry serves later changes that, so the fingerprint has to reach the host by some channel other than the key download.

The namespace’s first RPM key becomes its default. algorithm is rsa3072 by default, or rsa4096. The private key never leaves the registry, and no route returns it.

Read a key fingerprint

A host administrator who did not create the key can read the fingerprint from the registry:

  • The repository’s settings carry signing_key_fingerprint and, during a rotation, secondary_signing_key_fingerprint. Both are read-only.
  • Each of the namespace’s signing keys carries its own fingerprint.

To read the fingerprint of a key file you downloaded:

shell
gpg --show-keys --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-rpm-internal

During a rotation the file holds two keys, and the command prints a fingerprint for each.

Configure your client

An RPM repository is available at:

https://<registry_host>/<registry_handle>/rpm/<repository_name>

This URL has the following placeholders:

  • <registry_host>: Enter the hostname from your repository’s setup instructions. To find it, go to your repository and select More actions > View setup instructions.
  • <registry_handle>: Enter your organization’s registry handle.
  • <repository_name>: Enter the name of your repository.

Prerequisites:

  • Root access to the host.
  • A registry token.
  • The fingerprint of the repository’s signing key.

To add the repository to a host, create a .repo file in /etc/yum.repos.d/:

ini
# /etc/yum.repos.d/rpm-internal.repo
[rpm-internal]
name=rpm-internal
baseurl=https://ar.example.com/acme/rpm/rpm-internal
username=token
password=$artoken_ar_example_com_acme
repo_gpgcheck=1
gpgcheck=0
gpgkey=https://ar.example.com/acme/rpm/rpm-internal/repodata/repomd.xml.key
metadata_expire=5m
skip_if_unavailable=1
enabled=1

Then write the token to a variable file that only root can read:

shell
install -m 0600 /dev/null /etc/dnf/vars/artoken_ar_example_com_acme
printf '%s' "$ARTIFACT_REGISTRY_TOKEN" > /etc/dnf/vars/artoken_ar_example_com_acme

The configuration works as follows:

  • password=$artoken_ar_example_com_acme makes dnf read the token from /etc/dnf/vars/artoken_ar_example_com_acme. A file in /etc/yum.repos.d/ is mode 0644 by default, so every local user can read a token written into it. The variable file is readable by root alone.
  • The variable name carries the host and the registry handle from baseurl, as artoken_<host>_<handle>. A token reaches only its own organization, so hosts that read from two organizations need one file each. dnf accepts lowercase letters, digits, and underscores in a variable name, so each ., -, and : becomes _. The result is not unique: host x.y with handle z and host x with handle y-z both give artoken_x_y_z. A host that reads from two such repositories would share one token file, so do not add both to the same host.
  • metadata_expire=5m sets how long dnf trusts its cached index. Without it, dnf waits 48 hours before it asks again, however fast the registry publishes.
  • repo_gpgcheck=1 makes dnf check the index signature. The checksums in the signed index then cover each package.
  • gpgcheck=0 turns off the package signature check, because the registry does not sign packages. A publisher that signs its own packages imports its own key on the host before the first install.
  • gpgkey= stays on the registry host. dnf sends the repository credentials to whatever host gpgkey= names.
  • skip_if_unavailable=1 limits a credential failure to this repository. Without it, a failure here fails every repository on the host.

The token expires, so refresh the variable file before it does. For token lifetimes, see Token lifetime.

Import the key with dnf5

dnf5 sends no credentials when it fetches gpgkey=, so it cannot download the key of a private repository. On a dnf5 host, download the key with the token and point gpgkey= at the local file:

shell
curl --fail-with-body --user "token:$ARTIFACT_REGISTRY_TOKEN" \
  --output /etc/pki/rpm-gpg/RPM-GPG-KEY-rpm-internal \
  "https://ar.example.com/acme/rpm/rpm-internal/repodata/repomd.xml.key"
ini
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpm-internal

Check the fingerprint of the downloaded file against the one the registry reports, then download the file again after each key rotation. For more information, see Read a key fingerprint.

Hosts that cannot read the variable file

A dnf run without root cannot read the variable file. It sends the variable name as a literal string, the registry refuses it, and the run skips this repository with the same credential warning a bad token gives.

microdnf on RHEL 8 does not fill in variables in repository options, so it sends the literal string for the same reason. On such a host, for example a ubi8-minimal image, put the token directly in a .repo file of mode 0600 instead. RHEL 9 and later fill the variables in, so ubi9-minimal uses the configuration as shown.

Install a package

Prerequisites:

  • The Artifact Viewer role.
  • A .repo file on the host.

To install a package:

shell
dnf install hello

The first install fetches the repository index, finds it signed by a key the host does not trust, and asks to import the key from gpgkey=. The prompt reads Importing GPG key under dnf and Importing OpenPGP key under dnf5, and carries the key’s fingerprint: dnf prints it in groups of four characters and dnf5 prints it unspaced, the way the registry reports it. Check it against the fingerprint the registry reports before you confirm, because a host trusts the first key it imports and nothing the registry serves later changes that. For more information, see Read a key fingerprint.

A dnf5 host asks the same way, even though gpgkey= already points at a file you downloaded and checked. Where the key comes from does not change the import confirmation.

Publish a package

Prerequisites:

  • The Artifact Contributor role.
  • A registry token.

To publish a package:

shell
curl --fail-with-body --user "token:$ARTIFACT_REGISTRY_TOKEN" \
  --upload-file hello-1.0-1.x86_64.rpm \
  "https://ar.example.com/acme/rpm/rpm-internal/upload/"

curl --upload-file appends the local file name to a URL that ends in a slash, so keep the trailing slash.

The registry reads the package name, epoch, version, release, and architecture from the package header, never from the file name, and refuses a package whose file name disagrees with its header.

ConditionResult
The version is new201 Created
The version exists and the content is byte-for-byte identical200 OK
The version exists and the content differs409 Conflict with code package_exists
The file is not a valid package, its header is larger than the header size limit, or its name does not match its header422 Unprocessable Content with code invalid_package
The package is a new version and its name is at the versions limit422 Unprocessable Content with code version_count_exceeded
The package is larger than the package size limit413 Content Too Large with code request_entity_too_large
The namespace is at its storage quota429 Too Many Requests with code quota_exceeded

The registry also answers 401 for a missing or invalid credential, 403 for a caller that can read but not write, and 503 with a Retry-After header when it has no free upload slot. For more information, see Troubleshooting Artifact Central.

The package becomes installable when the next metadata rebuild commits.

Publish from CI/CD

A CI/CD job publishes with the same request. The registry does not accept a job token directly, so exchange the job token for a registry token in the job, then pass the registry token to curl:

yaml
publish-rpm:
  image: alpine:3.22
  before_script:
    - apk add --no-cache curl jq
    - |
      ARTIFACT_REGISTRY_TOKEN=$(curl --silent --show-error --fail --request POST \
        --header "JOB-TOKEN: $CI_JOB_TOKEN" \
        "$CI_API_V4_URL/token_exchange?audience=gitlab-artifact-registry&expires_in=3600" | jq --exit-status --raw-output .token)
      test -n "$ARTIFACT_REGISTRY_TOKEN"
      export ARTIFACT_REGISTRY_TOKEN
  script:
    - |
      curl --fail-with-body --user "token:$ARTIFACT_REGISTRY_TOKEN" \
        --upload-file hello-1.0-1.x86_64.rpm \
        "https://ar.example.com/acme/rpm/rpm-internal/upload/"

The job runs as the user who triggered the pipeline, and that user needs the Artifact Contributor role or higher on the repository. For more information, see Authenticate with Artifact Central.

Rotate a signing key

A rotation moves a repository from one key to another. dnf fetches the key only after a signature check fails, so widen the trust first and switch the signature second.

Prerequisites:

  • The Artifact Admin role for the organization.
  • The fingerprint of the new key.

To rotate a key:

  1. Create key B, then add it to the repository as the secondary key. The repository serves both public keys and still signs with key A, so a host that imports keys from now on gets both:

    shell
    curl --fail-with-body --request PATCH \
      --header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
      --header "Content-Type: application/json" \
      --data '{"settings": {"secondary_signing_key_id": "<key_b_id>"}}' \
      "https://<registry_host>/api/v1/<registry_handle>/repositories/<repository_name>"
  2. Make key B the signing key and key A the secondary key, in one request. A request that sets the signing key to the key it already holds as secondary returns 422 Unprocessable Content, so send both fields together:

    shell
    curl --fail-with-body --request PATCH \
      --header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
      --header "Content-Type: application/json" \
      --data '{"settings": {"signing_key_id": "<key_b_id>", "secondary_signing_key_id": "<key_a_id>"}}' \
      "https://<registry_host>/api/v1/<registry_handle>/repositories/<repository_name>"
  3. Let each host pick up key B. A host that trusts only key A fails its signature check once, then fetches the keys again and asks to import key B. Check the fingerprint before you confirm the import. On a dnf5 host, download the key again instead.

  4. When every host trusts key B, remove the secondary key:

    shell
    curl --fail-with-body --request PATCH \
      --header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
      --header "Content-Type: application/json" \
      --data '{"settings": {"secondary_signing_key_id": null}}' \
      "https://<registry_host>/api/v1/<registry_handle>/repositories/<repository_name>"

The registry sends no notice for a rotation, so tell your own hosts.

Removing a key from the repository only stops serving it. A host that already imported a key keeps trusting it until an operator removes it, so a compromised key has to be rotated on the hosts too.

To remove a key from a host, list the keys it trusts, then remove the one you want:

shell
rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION} %{SUMMARY}\n'
rpm -e --allmatches gpg-pubkey-<short_key_id>

rpm names an imported key after its short key ID, which is the last eight characters of the fingerprint in lowercase. A key whose fingerprint ends in 0680 8CE9 is gpg-pubkey-06808ce9.

Limit the packages a host installs

Anyone with the Artifact Contributor role can publish any package name, including the name of a system package at a higher version. A host that adds the repository trusts it for every package name.

To limit which packages a repository provides, add includepkgs= or exclude= to its .repo file:

ini
includepkgs=hello,internal-*

Remove a token from a support archive

sos report copies /etc/dnf/ into its archive and masks only password= lines. The token in the variable file is not masked, so it reaches the archive in cleartext. Remove the variable file from the archive before you share it, and treat any token in an archive you already shared as exposed.

Limits

LimitValue
Package size5 GB
Package header size32 MB
Versions per package25,000
Signing keys per namespace20

For the full list of limits, see Artifact Central limits.

Troubleshooting

Error: repomd.xml GPG signature verification error

The host does not trust the key that signed the index. This error follows a key rotation on a host that still trusts only the previous key. The message ends differently by release, because dnf verifies through a different OpenPGP library on each: Bad GPG signature on RHEL 8 and 9, and Signing key not found on RHEL 10 and Fedora. Both mean the same thing.

On a dnf host, run the install again and confirm the key import when asked, after you check the fingerprint. On a dnf5 host, download the key again.

Error: Status code: 401 when fetching the key

dnf5 sends no credentials when it fetches gpgkey=, so a private repository answers 401. Download the key with the token and point gpgkey= at the local file. For more information, see Import the key with dnf5.

dnf skips the RPM repository

A dnf run that reports a credential failure and skips the repository either ran without root, or ran as root with an expired or missing token in its variable file. The two look the same: a run without root cannot read the variable file, so dnf sends the variable name as a literal string and the registry refuses it, exactly as it refuses a bad token. Check that you ran as root before you refresh the token. For more information, see Hosts that cannot read the variable file.

skip_if_unavailable=1 is what keeps either failure to this repository instead of failing every repository on the host.

Error: 404 Not Found from every RPM route

The namespace does not have RPM enabled. The registry answers an RPM route in such a namespace the same way it answers an unknown namespace, so a healthy namespace returns 404 Not Found until RPM is turned on for it.