brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Signed-By ties an apt repository to its own key instead of trusting it for everything

Apt
~/tips/tip-apt-signed-by-keyring

sudo install -d -m 0755 /etc/apt/keyrings

Limits a third party key so it can only sign its own repository.

The old way of adding a vendor key put it in a keyring that apt trusts for every repository. That vendor could then sign packages that look like they came from Ubuntu. Signed-By limits a key to one source.

Store the key in /etc/apt/keyrings/, a folder meant for keys you manage yourself, and point the repository at it:

sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://example.com/repo/key.asc | sudo gpg --dearmor -o /etc/apt/keyrings/vendor.gpg
Types: deb
URIs: https://example.com/repo
Suites: stable
Components: main
Signed-By: /etc/apt/keyrings/vendor.gpg

Now apt only accepts packages from that repository if they are signed with that key, and the key is useless for any other repository. Without the field, apt falls back to every key in trusted.gpg and trusted.gpg.d/.

On older setups I’d look for keys in /etc/apt/trusted.gpg.d/ that belong to a single vendor repository. Moving them to /etc/apt/keyrings/ plus a Signed-By line closes that gap.

The key file must be readable by the _apt user, so keep it at 0644. The one-line format uses the same idea in brackets: deb [signed-by=/etc/apt/keyrings/vendor.gpg] https://example.com/repo stable main. Get the key from the vendor’s documented URL over HTTPS and compare its fingerprint with what they publish, because Signed-By only helps if the key itself is the right one.

Further reading: sources.list(5) manual page, Debian wiki: DebianRepository/UseThirdParty

More Apt tips sudo apt-mark minimize-manual apt list '~c' grep -E ' (install|upgrade|remove) ' /var/log/dpkg.log | tail -o Dpkg::Options::="–force-confold" upgrade sudo apt-get -d -y full-upgrade All Apt tips (42) All topics

Link