sources.list and signed-by: the current way to add an apt repository
Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan
Every feature on every plan, with unlimited users. 14 days free. No credit card required.
Start free trialStarting at $99/month billed annually.
apt reads its active sources from /etc/apt/sources.list and from .list or .sources files inside /etc/apt/sources.list.d/. A source line names the entry type (deb or deb-src), any options in square brackets, a URI, a suite, and components. Ubuntu 24.04 LTS (Noble) and Debian 13 have moved from /etc/apt/sources.list to deb822 .sources files in /etc/apt/sources.list.d/, and apt-key is deprecated in favor of signed-by keyring files. Below is how apt reads its repository list today, both file formats, keyrings, authenticated repositories, and how to check which sources a host uses.
Where apt keeps its sources
/etc/apt/sources.list and the files in /etc/apt/sources.list.d/ are designed to support any number of active sources and a variety of source media, according to the sources.list(5) man page. Each file inside /etc/apt/sources.list.d/ needs either the .list extension or the .sources extension depending on its format. Filenames may only contain letters (a-z and A-Z), digits (0-9), underscore (_), hyphen (-), and period (.).
The .list extension is for the one-line format, which is deprecated and may eventually be removed, though not before 2029. The .sources extension is for the deb822 format, which apt has supported since version 1.1. The man page notes that deb822 is intended to gradually become the default format because it is easier to create, extend, and modify for humans and machines alike.
For new systems, sources.list(5) suggests /etc/apt/sources.list.d/vendor.sources in deb822-style format, where vendor is the result of dpkg-vendor --query Vendor | tr A-Z a-z.
- On Ubuntu, the Ubuntu Server package management guide states that repositories are defined in
/etc/apt/sources.list.d/ubuntu.sources. Ubuntu releases prior to 24.04 LTS (Noble) do not use the deb822 standard by default, so they store their repository list in/etc/apt/sources.list. - On Debian 13, the Debian 13 release notes state that
/etc/apt/sources.listand*.listfiles in/etc/apt/sources.list.d/are replaced by.sourcesfiles in/etc/apt/sources.list.d/using the deb822-style format. Debian recommends a singledebian.sourcesfile in/etc/apt/sources.list.d/. If you have not switched all your configuration files yet, Debian 13 providesapt modernize-sources.
| File | Format | Default on |
|---|---|---|
/etc/apt/sources.list |
One-line (.list) |
Ubuntu releases prior to 24.04 LTS (Noble); replaced in Debian 13 |
/etc/apt/sources.list.d/ubuntu.sources |
deb822 (.sources) |
Ubuntu (24.04 LTS Noble and later) |
/etc/apt/sources.list.d/debian.sources |
deb822 (.sources) |
Debian 13 (recommended Debian repository list) |
/etc/apt/sources.list.d/vendor.sources |
deb822 (.sources) |
New systems (suggested by sources.list(5)) |
The one-line format and the .sources format
In the one-line format (.list files), each source sits on a single line:
deb [ option1=value1 option2=value2 ] uri suite [component1] [component2] [...]Options are separated by spaces and enclosed together in square brackets ([]), placed after the type and separated from it by a space. deb-src lines follow the same form. When an option takes multiple values in a one-line entry, those values are separated by commas.
In the deb822 format (.sources files), each entry is a stanza with named fields:
Types: deb deb-srcURIs: uriSuites: suiteComponents: [component1] [component2] [...]option1: value1option2: value2In deb822 files, multiple values are separated by whitespace such as spaces, tabs, or newlines instead of commas. Adding Enabled: no to a stanza turns that entry off.
Here is the Debian 13 example from sources.list(5) in the one-line .list format:
deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian trixie main contrib non-free non-free-firmwareHere is the man page’s Debian 13 example in deb822 .sources format, with both trixie and trixie-updates listed under Suites:
Types: debURIs: http://deb.debian.org/debianSuites: trixie trixie-updatesComponents: main contrib non-free non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpgsigned-by and keyrings, now that apt-key is deprecated
apt-key is titled “Deprecated APT key management utility” in the apt-key(8) man page. Use of apt-key is deprecated, except for apt-key del inside maintainer scripts to remove existing keys from the main keyring.
Instead of adding keys globally, use the Signed-By field in a .sources stanza or the signed-by option in a .list line. Signed-By requires a repository to pass apt-secure(8) verification against a specific set of keys rather than all trusted keys apt has configured. If no keyring files are specified, apt defaults to the trusted.gpg keyring and all keyrings in the trusted.gpg.d/ directory.
Specify signed-by as a list of absolute paths to keyring files, along with fingerprints of keys to select from those keyrings when needed. sources.list(5) recommends two keyring directories:
/usr/share/keyringsfor keyrings managed by packages./etc/apt/keyringsfor keyrings managed by the system operator.
Keyring files have to be accessible and readable for the _apt system user, so ensure everyone has read permissions on the file. Before using any key added by hand, verify that it belongs to the owner of the repository it claims to be for; otherwise, as apt-key(8) warns, the apt-secure(8) infrastructure is completely undermined.
A repository that needs a login
As the apt_auth.conf(5) man page notes, login information needed to connect to a proxy or download data from a repository should not always be accessible by everyone and therefore cannot be placed in a file with world-readable file permissions.
apt reads login details from /etc/apt/auth.conf and from .conf files inside /etc/apt/auth.conf.d, stored in a netrc-like format with restrictive file permissions. Login information in auth.conf is also more flexible than putting credentials in sources.list.
apt matches entries by searching for a machine token that matches the hostname of the URI it needs login information for. A machine entry may also include a path, such as example.org/debian/. Here is the example from apt_auth.conf(5):
machine example.orglogin aptpassword debianSee which repositories a host uses
To inspect the apt list of repositories configured on a host, check /etc/apt/sources.list and the .list or .sources files inside /etc/apt/sources.list.d/. To see the priorities of each active source as apt reads them, run apt-cache policy with no arguments:
apt-cache policyThe apt-cache(8) man page notes that policy has the form policy [pkg...] and is meant to help debug issues relating to the preferences file. Without arguments, it prints out the priorities of each source.
If you prefer a script to manage external entries, add-apt-repository adds an external APT repository to either /etc/apt/sources.list or a file in /etc/apt/sources.list.d/, or removes an already existing repository. Its form is add-apt-repository [OPTIONS] [LINE].
Where CloudRepo fits
CloudRepo is a fully managed artifact repository. There is nothing to host, patch, or upgrade, because we run it for you.
CloudRepo’s apt proxy repositories are in early access. An apt proxy puts a Debian or Ubuntu archive behind your organization’s CloudRepo address, and apt reads it as a source. The archives it reads include Debian (deb.debian.org/debian), Ubuntu (archive.ubuntu.com/ubuntu), and Docker’s own apt archive for Ubuntu and for Debian. One apt proxy reads one archive.
Your hosts use the same two files this guide covers: one source line in /etc/apt/sources.list.d/, with signed-by naming the distribution’s own keyring, and a login file in /etc/apt/auth.conf.d/. The Ubuntu source line looks like this:
deb [signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] https://your-org.mycloudrepo.io/repositories/your-repo noble mainYour token sits in a login file under /etc/apt/auth.conf.d/, never in the source line.
apt proxy repositories are on every plan. For every setup line, step by step, see the apt repositories page and the docs.
If your Linux servers also use dnf or zypper, yum proxy repositories, in early access, are live today: create a yum proxy, point dnf or zypper at it, and your Linux servers install their packages through CloudRepo. For the client file format, see the dnf and yum .repo file guide.
More: apt repositories, yum proxy repositories, dnf and yum .repo file guide, all client guides, and the CloudRepo roadmap.
Every feature on every plan, with unlimited users
14 days free. No credit card required.
Starting at $99/month billed annually.
Founder-run since 2016, with no venture capital. A real person answers within one business day. Usually it's me.
Chris, founder of CloudRepo
More guides
- How to point npm at a private registry with .npmrc 4 min
- Docker pull-through cache: four ways to set one up 4 min
- docker login to a private registry from a laptop, CI and Kubernetes 4 min
- pip.conf, index-url and extra-index-url: install from a private index safely 4 min
- Maven settings.xml mirrors: send every build through one repository 4 min
- GOPROXY, GOPRIVATE and GONOSUMDB: what to set for private modules and a proxy 8 min
- nuget.config for a private feed 8 min
- The .repo file for dnf, yum and zypper 7 min