使用apt时gpg出现问题

使用apt时gpg出现问题

我正在绞尽脑汁寻找一种方法来纠正apt.

当我尝试安装 Nodejs 时:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

我收到此错误:

## You seem to be using Debian version stretch.
## This maps to Debian "jessie"... Adjusting for you...

## Confirming "jessie" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_7.x/dists/jessie/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
gpg: [don't know]: invalid packet (ctb=00)
gpg: keydb_get_keyblock failed: Valeur non trouvée
gpg: [don't know]: invalid packet (ctb=00)
gpg: /tmp/apt-key-gpghome.ix2LFsfXOw/pubring.gpg: copy to '/tmp/apt-key-gpghome.ix2LFsfXOw/pubring.gpg.tmp' failed: Paquet incorrect
gpg: error writing keyring '/tmp/apt-key-gpghome.ix2LFsfXOw/pubring.gpg': Paquet incorrect
gpg: [don't know]: invalid packet (ctb=00)
gpg: error reading '-': Paquet incorrect
gpg: import from '-' failed: Paquet incorrect
Error executing command, exiting

我使用内核为 10.5 的 Debian Stretch rc2。不知道是不是这个问题。我无法使用稳定版本的 debian,因为我在 Ryzen 处理器上运行。

当我尝试安装 VSCode 时,我也遇到了另一个错误:

W: Erreur de GPG : http://packages.microsoft.com/repos/vscode stable InRelease : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY EB3E94ADBE1229CF
W: The repository 'http://packages.microsoft.com/repos/vscode stable InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

任何想法?

[编辑] 这是我的来源列表

deb http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch main non-free contrib 
deb-src http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch main non-free contrib 

deb http://security.debian.org/debian-security/ stretch/updates main contrib non-free 
deb-src http://security.debian.org/debian-security/ stretch/updates main contrib non-free 

# stretch-updates, previously known as 'volatile'
deb http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch-updates main contrib non-free 
deb-src http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch-updates main contrib non-free 

# stretch-backports, previously on backports.debian.org
deb http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch-backports main contrib non-free 
deb-src http://ftp.univ-pau.fr/linux/mirrors/debian/ stretch-backports main contrib non-free 

# deb [arch=amd64] https://download.docker.com/linux/debian/ stretch stable 
# deb-src [arch=amd64] https://download.docker.com/linux/debian/ stretch stable 
deb http://www.deb-multimedia.org/ stretch main non-free 
deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main

答案1

我知道这是一个老问题,可能会被事件克服(OBE)......但是......

似乎有几个问题巧合地同时出现。

问题一: Nodejs 存储库 GPG 公钥

我下载密钥时没有遇到任何问题,因此也许存储库在那天遇到了连接问题或其他一些故障。

这是我读取回购公钥的测试:

$ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key |gpg --list-packets

# off=0 ctb=99 tag=6 hlen=3 plen=525
:public key packet:
    version 4, algo 1, created 1402676406, expires 0
    pkey[0]: [4096 bits]
    pkey[1]: [17 bits]
    keyid: 1655A0AB68576280
# off=528 ctb=b4 tag=13 hlen=2 plen=31
:user ID packet: "NodeSource <[email protected]>"
# off=561 ctb=89 tag=2 hlen=3 plen=568
:signature packet: algo 1, keyid 1655A0AB68576280
    version 4, created 1402676406, md5len 0, sigclass 0x13
    digest algo 2, begin of digest 74 e6
    hashed subpkt 2 len 4 (sig created 2014-06-13)
    hashed subpkt 27 len 1 (key flags: 03)
    hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2)
    hashed subpkt 21 len 5 (pref-hash-algos: 8 2 9 10 11)
    hashed subpkt 22 len 3 (pref-zip-algos: 2 3 1)
    hashed subpkt 30 len 1 (features: 01)
    hashed subpkt 23 len 1 (keyserver preferences: 80)
    subpkt 16 len 8 (issuer key ID 1655A0AB68576280)
    data: [4095 bits]
# off=1132 ctb=b9 tag=14 hlen=3 plen=525
:public sub key packet:
    version 4, algo 1, created 1402676406, expires 0
    pkey[0]: [4096 bits]
    pkey[1]: [17 bits]
    keyid: 6C5CDECAAA01DA2C
# off=1660 ctb=89 tag=2 hlen=3 plen=543
:signature packet: algo 1, keyid 1655A0AB68576280
    version 4, created 1402676406, md5len 0, sigclass 0x18
    digest algo 2, begin of digest 83 d0
    hashed subpkt 2 len 4 (sig created 2014-06-13)
    hashed subpkt 27 len 1 (key flags: 0C)
    subpkt 16 len 8 (issuer key ID 1655A0AB68576280)
    data: [4096 bits]

问题2: Microsoft 存储库 GPG 公钥

这里的问题是 Microsoft 公钥位于 Microsoft 存储库服务器上的单独目录中。

我在以下位置找到了密钥文件:

https://packages.microsoft.com/keys/microsoft.asc

这是我读取微软仓库公钥的测试:

$ curl -s https://packages.microsoft.com/keys/microsoft.asc |gpg --list-packets
# off=0 ctb=99 tag=6 hlen=3 plen=269
:public key packet:
    version 4, algo 1, created 1446074508, expires 0
    pkey[0]: [2048 bits]
    pkey[1]: [17 bits]
    keyid: EB3E94ADBE1229CF
# off=272 ctb=b4 tag=13 hlen=2 plen=55
:user ID packet: "Microsoft (Release signing) <[email protected]>"
# off=329 ctb=89 tag=2 hlen=3 plen=309
:signature packet: algo 1, keyid EB3E94ADBE1229CF
    version 4, created 1446074508, md5len 0, sigclass 0x13
    digest algo 2, begin of digest 1a 9b
    hashed subpkt 2 len 4 (sig created 2015-10-28)
    hashed subpkt 27 len 1 (key flags: 03)
    hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2)
    hashed subpkt 21 len 3 (pref-hash-algos: 2 8 3)
    hashed subpkt 22 len 2 (pref-zip-algos: 2 1)
    hashed subpkt 30 len 1 (features: 01)
    hashed subpkt 23 len 1 (keyserver preferences: 80)
    subpkt 16 len 8 (issuer key ID EB3E94ADBE1229CF)
    data: [2047 bits]

问题3: 存储库 URL 中缺少正斜杠

/etc/apt/sources.list您的 Microsoft 存储库行中缺少一个正斜杠。

这行:

deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main

应该:

deb [arch=amd64] http://packages.microsoft.com/repos/vscode/ stable main

完整的解决方案

  1. 重新尝试安装nodejs
  2. 添加缺少的正斜杠/etc/apt/sources.list
  3. 下载并添加 Microsoft 的存储库签名密钥:

curl -s https://packages.microsoft.com/keys/microsoft.asc |apt-key add -

相关内容