如何在Debian上重新生成/etc/apt/trustdb.gpg?


9

假设其中一个删除(或损坏)了以下文件。

/etc/apt/trustdb.gpg

如何再生呢?

Answers:


9

我发现了这两种方法。第一种似乎是最安全的方法。

方法1-使用apt

$ sudo -i
$ apt-get clean
$ cd /var/lib/apt
$ mv lists lists.old
$ mkdir -p lists/partial
$ apt-get clean
$ apt-get update

方法2-apt键

您可以使用此命令apt-key生成相应的gpg命令,以下载适用于Canonical的密钥。

$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
Executing: 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 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: key 437D05B5: "Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>" 25 new signatures
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: new signatures: 25

发生了什么?

如果使用此命令,则可以窥探第二种方法:

$ 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/'\'''
...

此命令也可以作为普通用户而不是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 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: error writing keyring `/etc/apt/trusted.gpg': file write error
gpg: key 437D05B5: "Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>" 26 new signatures
gpg: error reading `[stream]': file write error
gpg: Total number processed: 0
gpg:         new signatures: 26

参考文献


为什么keyserver.ubuntu.com选择Debian?
潘迪
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.