更新apt失败了

apt update 出错了。


$ sudo apt update
Hit:1 https://deb.debian.org/debian buster InRelease
Hit:2 https://deb.debian.org/debian-security buster/updates InRelease                        
Hit:3 https://packages.cloud.google.com/apt cloud-sdk InRelease                              
Ign:4 https://storage.googleapis.com/cros-packages/84 buster InRelease                       
Hit:6 https://storage.googleapis.com/cros-packages/84 buster Release   
Get:5 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease [23.4 kB]
Err:5 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
Reading package lists... Done
W: GPG error: https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
E: The repository 'https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

从错误信息来看,验证证书似乎是问题的原因。

所以,需要添加证书如下:


$ sudo apt-get -qO - https://packagecloud.io/headmelted/codebuilds/gpgkey | sudo apt-key add -
OK

证书管理可以通过apt-key命令进行。


$ apt-key help
Usage: apt-key [--keyring file] [command] [arguments]

Manage apt's list of trusted keys

  apt-key add <file>          - add the key contained in <file> ('-' for stdin)
  apt-key del <keyid>         - remove the key <keyid>
  apt-key export <keyid>      - output the key <keyid>
  apt-key exportall           - output all trusted keys
  apt-key update              - update keys using the keyring package
  apt-key net-update          - update keys using the network
  apt-key list                - list keys
  apt-key finger              - list fingerprints
  apt-key adv                 - pass advanced options to gpg (download key)

If no specific keyring file is given the command applies to all keyring files.

请参考

Ubuntu 手册:apt-key – APT 密钥管理实用程序