Suppose one deleted (or damaged) the following file./etc/apt/trustdb.gpgHow to regenerate it?
How to regenerate /etc/apt/trustdb.gpg on Debian?
debian;apt;gpg
I found these 2 methods for doing it. The first seems like the safest way to do it.Method #1 - using apt$ sudo -i$ apt-get clean$ cd /var/lib/apt$ mv lists lists.old$ mkdir -p lists/partial$ apt-get clean$ apt-get updateMethod #2 - apt-keyYou can use this command to get apt-key to generate the corresponding gpg command to download the appropriate key for Canonical.$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.comgpg: key 437D05B5: Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> 25 new signaturesgpg: no ultimately trusted keys foundgpg: Total number processed: 1gpg: new signatures: 25What's happening?You can spy a bit on the second method if you use this command:$ sudo -i$ bash -x apt-key update |& less+ set -e+ unset GREP_OPTIONS++ mktemp+ SECRETKEYRING=/tmp/tmp.ZhVikJSB3s+ trap 'rm -f '\''/tmp/tmp.ZhVikJSB3s'\''' 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM+ GPG_CMD='gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.ZhVikJSB3s'++ id -u+ '[' 0 -eq 0 ']'++ apt-config shell TRUSTDBDIR Dir::Etc/d+ eval 'TRUSTDBDIR='\''/etc/apt/'\'''...This command can also be used, as a regular user, not root!:$ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5                             Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.kZ1TEwcI5s --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.comgpg: error writing keyring `/etc/apt/trusted.gpg': file write errorgpg: key 437D05B5: Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> 26 new signaturesgpg: error reading `[stream]': file write errorgpg: Total number processed: 0gpg:         new signatures: 26ReferencesFixing apt-get GPG Invalid Signature in ubuntuErrors when updating package list with apt-get on (K)ubuntuApt-get Update GPG Key Errors and Fix