Debian: How to add an external repository to unattended upgrades

In this post, we’ll be using Rspamd as an example.

apt-cache policy

Look for the repository you want to add, e.g.: Rspamd.

500 http://rspamd.com/apt-stable bookworm/main amd64 Packages
     release o=Rspamd,n=bookworm,l=Rspamd,c=main,b=amd64
     origin rspamd.com

Look up in which field the distribution is recorded. Sometimes “n” (shorthand for codename) like in this case, but usually “a” (architecture).

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Within the Unattended-Upgrade::Origins-Pattern section, add the value found in the apt-cache policy output. Optionally, replace bookworm with ${distro_codename} so the setting will remain valid after a Debian version upgrade.

"o=Rspamd,n=${distro_codename}";

In Debian 10 ‘Buster’ and later versions, in addition to this, the site keyword may also be used.

sudo nano /etc/apt/sources.list
"o=Rspamd,n=${distro_codename},site=rspamd.com";

Closing thoughts

I welcome your feedback and hearing about your experiences! If this post has been useful to you, please feel free to leave a comment down below.