Debian packages in Artifact Central
- Tier: Premium, Ultimate
- Offering: GitLab.com
- Status: Beta
Debian repositories are available only in namespaces where the registry has Debian enabled.
Until then, every Debian route in the namespace returns 404 Not Found, the same answer an
unknown namespace returns.
A Debian repository in Artifact Central stores binary .deb packages and serves them to apt as
a signed Debian archive.
The registry builds the archive index itself and signs it. It does not sign the packages in it.
Debian is available for hosted repositories only.
Supported clients
| Client | Support |
|---|---|
apt | Debian 10 to 13 and Ubuntu 20.04 to 26.04. Works with the configuration on this page. |
curl | Any host. Publishes packages. The examples that use --fail-with-body need curl 7.76 or later. |
Authenticate
apt and curl 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:
export ARTIFACT_REGISTRY_TOKEN="$(glab artifact-registry get-token)"Create a signing key
A Debian repository signs its index with a key from its namespace. A repository that names no key uses the namespace default key. You cannot create a Debian repository in a namespace that has no Debian key. Debian keys and RPM keys are separate, so a Debian repository cannot use an RPM key.
Prerequisites:
- The Artifact Admin role for the organization.
- A registry token.
To create a key:
curl --fail-with-body --request POST \
--header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
--header "Content-Type: application/json" \
--data '{"name": "apt-internal", "algorithm": "rsa3072"}' \
"https://<registry_host>/api/v1/<registry_handle>/debian/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 Debian 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 fingerprints of the namespace’s keys from the registry:
curl --fail-with-body \
--header "Authorization: Bearer $ARTIFACT_REGISTRY_TOKEN" \
"https://<registry_host>/api/v1/<registry_handle>/debian/signing_keys"Each key in the signing_keys list carries its own fingerprint.
The request needs the read_repository permission on the namespace.
Use this value only as a consistency check. A network attacker can change it together with the key, so compare the key file against the fingerprint that the key’s creator passed on.
To read the fingerprint of a key file you downloaded:
gpg --show-keys --with-fingerprint /etc/apt/keyrings/apt-internal.ascConfigure your client
A Debian repository is available at:
https://<registry_host>/<registry_handle>/debian/<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.
The GitLab CLI has no command for apt yet, so write the configuration by hand.
Prerequisites:
- Root access to the host.
- A registry token.
- The fingerprint of the repository’s signing key.
To add the repository to a host:
Download the repository’s public key. Debian 10 and 11 and Ubuntu 20.04 have no
/etc/apt/keyrings/directory, so create it first:install -d -m 0755 /etc/apt/keyrings curl --fail --user "token:$ARTIFACT_REGISTRY_TOKEN" \ --output /etc/apt/keyrings/apt-internal.asc \ "https://ar.example.com/acme/debian/apt-internal/key.asc"Check the fingerprint of the downloaded file against the one the key’s creator gave you. The registry reports the same fingerprint, but it serves it over the same connection as the key, so it does not prove the key is genuine. For more information, see Read a key fingerprint.
Create the source file:
# /etc/apt/sources.list.d/apt-internal.sources Types: deb URIs: https://ar.example.com/acme/debian/apt-internal Suites: bookworm Components: main Signed-By: /etc/apt/keyrings/apt-internal.ascWrite the token to a credential file that only root can read:
install -m 0600 /dev/null /etc/apt/auth.conf.d/apt-internal.conf cat > /etc/apt/auth.conf.d/apt-internal.conf <<EOF machine ar.example.com/acme/debian/apt-internal/ login token password $ARTIFACT_REGISTRY_TOKEN EOFUpdate the package index:
apt-get update
The configuration works as follows:
Signed-Bynames a file, because Debian 10 and 11 and Ubuntu 20.04 do not accept a key inside theSigned-Byfield.- The
machinevalue is theURIsvalue withouthttps://, with the port if the URL has one, and it ends in/.aptmatches it as a prefix of the request’s host, port, and path, and uses the first file that matches. Without the final/, the entry forapt-internalalso matches every request toapt-internal2. aptsends anauth.confcredential whosemachinehas no scheme only overhttps. Debian 10 withapt1.8.2 also sends it over plainhttp.- A file in
/etc/apt/sources.list.d/is readable by every local user, so keep the token inauth.conf.d/.
The token expires, so refresh the credential file before it does. For token lifetimes, see Token lifetime.
Refresh the token
apt reads the token only from a file on disk.
To refresh it, write the file again with a new token:
ARTIFACT_REGISTRY_TOKEN="$(glab artifact-registry get-token --duration 12h)"
install -m 0600 /dev/null /etc/apt/auth.conf.d/apt-internal.conf
cat > /etc/apt/auth.conf.d/apt-internal.conf <<EOF
machine ar.example.com/acme/debian/apt-internal/
login token
password $ARTIFACT_REGISTRY_TOKEN
EOFA token lasts 12 hours at most. A host that stays current needs a job that runs this refresh, and that job holds a GitLab credential that outlives the registry token.
Use a registry without TLS
A registry that serves plain http needs two changes.
Write the URIs value with http, and write the credential file with both forms of the machine
value.
apt 1.9.5 and later send an auth.conf credential over plain http only when machine names the
scheme.
Debian 10 reads only a machine value without a scheme:
# /etc/apt/sources.list.d/apt-internal.sources
URIs: http://ar.example.com:8080/acme/debian/apt-internal# /etc/apt/auth.conf.d/apt-internal.conf
machine http://ar.example.com:8080/acme/debian/apt-internal/
login token
password <token>
machine ar.example.com:8080/acme/debian/apt-internal/
login token
password <token>Plain http sends the token in cleartext, so use it only on a network you control.
Install a package
Prerequisites:
- The Artifact Viewer role.
- A source file and a credential file on the host.
To install a package:
apt-get update
apt-get install helloapt-get update asks for InRelease of each suite and checks its signature against the
Signed-By file.
A repeated apt-get update with no change costs one 304 Not Modified response for each suite.
Run apt-get update as root, because only root can read the credential file.
Publish a package
Prerequisites:
- The Artifact Contributor role.
- A registry token.
- A binary
.debfile.
To publish a package:
curl --fail-with-body --user "token:$ARTIFACT_REGISTRY_TOKEN" \
--upload-file hello_1.0-1_amd64.deb \
"https://ar.example.com/acme/debian/apt-internal/upload/bookworm/main/"The URL has the form .../upload/<suite>/<component>/.
The registry creates the suite and the component on the first upload that names them.
curl --upload-file appends the local file name to a URL that ends in a slash, so keep the
trailing slash.
The route accepts any file name that ends in .deb, such as a GoReleaser
{name}_{version}_{os}_{arch}.deb.
The registry reads the package name, version, and architecture from the control file in the
package, and stores the package under {name}_{version}_{arch}.deb.
It accepts only a .deb on this route.
It refuses a source upload (.dsc, .orig.tar.*, .debian.tar.*), a .udeb, a .ddeb, and a
.changes file with 422 Unprocessable Content and code unsupported_file_type.
A package with Architecture: all appears in the index of every architecture of its suite.
When the upload adds such a package to a suite, the suite gains amd64 and arm64 if it lacks
them, so hosts of those architectures can install the package.
| Condition | Result |
|---|---|
| The version is new | 201 Created |
| The version exists in the same suite and the content is byte-for-byte identical | 200 OK |
| The version exists only in another suite and the content is byte-for-byte identical | 201 Created |
| The version exists in any suite of the repository with different content | 409 Conflict with code package_exists |
| The file is not a valid package | 422 Unprocessable Content with code invalid_package |
The file name does not end in .deb | 422 Unprocessable Content with code unsupported_file_type |
| A suite, component, or architecture limit is reached | 422 Unprocessable Content with code limit_exceeded |
| The package is a new version and its name is at the versions limit | 422 Unprocessable Content with code version_count_exceeded |
| The package is larger than the package size limit | 413 Content Too Large with code request_entity_too_large |
| The namespace is at its storage quota | 429 Too Many Requests with code quota_exceeded |
The 409 response names each conflicting package name, version, and architecture, and the suite
that holds the existing bytes.
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.
The registry answers 404 when the path breaks the name rules, or the repository is missing, not
Debian, or not readable by the caller.
For more information, see Troubleshooting Artifact Central.
A retry of a failed upload is safe. A retry after a lost 201 answers 200.
A new package appears in apt-get update within 60 seconds for 99 percent of uploads, when the
package indexes that the rebuild changes hold up to 50 MB in all before compression.
Build a binary-only package
The registry stores binary packages only.
Build the package without the source files, for example with dpkg-buildpackage -b or
debuild -b, and upload the resulting .deb file.
Publish one version for each distribution build
A version is unique on its package name, version, and architecture in a repository.
Two versions are the same when dpkg compares them as equal, so 1.0 and 0:1.0 are one version,
and so are 1.01 and 1.1.
A suite and a second suite of the same repository cannot hold different bytes under one name,
version, and architecture, and an all build cannot share a name and version with a build for
another architecture.
To publish a build for each distribution, give each build its own version, such as 1.0-1~deb12u1
and 1.0-1~deb13u1, or use one repository for each distribution.
Publishing the same bytes to a second suite works, and it stores the package once.
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:
publish-deb:
image: debian:12-slim
before_script:
- apt-get update && apt-get install --yes --no-install-recommends ca-certificates 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_amd64.deb \
"https://ar.example.com/acme/debian/apt-internal/upload/bookworm/main/"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.
Fail a job when apt-get update fails
apt-get update exits 0 when it cannot fetch one source, so a job that installs from the
repository can continue with an old index.
To fail the job instead, add --error-on=any:
apt-get update --error-on=anyDebian 10 has apt 1.8.2, which does not accept --error-on=any.
On Debian 10, fail the job when the output has a W: line:
apt-get update 2>&1 | tee /tmp/apt-update.log
if grep --quiet '^W:' /tmp/apt-update.log; then exit 1; fiLimit 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, unless you pin it.
A pin uses the Origin and Label of the repository’s Release file.
Origin is the registry handle and Label is the repository name, and neither changes while the
repository exists.
To keep the repository from replacing a package that another source provides, and to prefer it for
the packages you name, create a preferences file:
# /etc/apt/preferences.d/apt-internal.pref
Package: *
Pin: release o=acme,l=apt-internal
Pin-Priority: 100
Package: hello internal-*
Pin: release o=acme,l=apt-internal
Pin-Priority: 600The first stanza gives every package from the repository a priority below the Debian default of 500, so a package that Debian also provides comes from Debian. The second stanza raises the priority of the packages you name above it.
Sync the host clock
The registry dates each Release file with its own clock.
A host whose clock runs more than 10 seconds behind the registry’s refuses a Release file dated
in its future.
apt-get update fails after each publish until the host clock catches up.
Keep the clock of every host and CI/CD runner synchronized, for example with chrony or
systemd-timesyncd.
Limits
| Limit | Value |
|---|---|
| Package size | 5 GB |
| Control file size, decompressed | 1 MB |
| Versions per package | 25,000 |
| Suites per repository | 100 |
| Components per suite | 20 |
| Architectures per suite | 20 |
| Signing keys per namespace | 20 |
For the full list of limits, see Artifact Central limits.
Troubleshooting
Error: 401 Unauthorized from apt-get update
The token in the credential file expired, or the machine value does not match the URIs value.
Check that the machine value is the URIs value without https://, and that it ends in /.
A registry on plain http needs two machine values. For more information, see
Use a registry without TLS.
Then refresh the token. For more information, see Refresh the token.
Error: NO_PUBKEY or The repository is not signed
The host does not trust the key that signed the index.
Check that Signed-By names the file you downloaded, and that the file holds the key of the
repository.
Error: Release file is not valid yet
The clock of the host is behind the registry’s. For more information, see Sync the host clock.
Error: Hash Sum mismatch
A host read an InRelease file older than every index the registry still serves.
Run apt-get update again.
Error: 404 Not Found from every Debian route
The namespace does not have Debian enabled.
The registry answers a Debian route in such a namespace the same way it answers an unknown
namespace, so a healthy namespace returns 404 Not Found until Debian is turned on for it.