为什么 GnuPG 2 和 gpg-connect-agent 失败并显示“ERR 67108983 No SmartCard daemon”?

Jen*_*rat 13 debian smartcard gnupg yubikey openpgp

使用 Debian Jessie 和 GnuPG 2,每次我尝试使用 GnuPG 2 ( gpg2) 或gpg-connect-agent与 OpenPGP 智能卡(在我的情况下为 YubiKey)一起使用时,操作失败并显示一条消息

$ gpg-connect-agent --hex "scd apdu 00 f1 00 00" /bye
ERR 67108983 No SmartCard daemon <GPG Agent>
$ gpg2 --card-status
ERR 67108983 No SmartCard daemon <GPG Agent>
Run Code Online (Sandbox Code Playgroud)

使用旧版 GnuPG 1 ( gpg) 时,一切正常。

这里出了什么问题?

Jen*_*rat 21

scdaemon 不见了

GnuPG 2 通过 连接到卡gpg-agent,这同样不包括智能卡功能,而是通过另一个应用程序访问它们。这可以配置并具有系统相关的默认值,来自man gpg-agent

--scdaemon-program filename
      Use program filename as the Smartcard daemon.  The default is
      installation dependent and can be shown with the gpgconf command.
Run Code Online (Sandbox Code Playgroud)

这样做会显示 GnuPG 尝试运行/usr/lib/gnupg2/scdaemon

$ gpgconf
gpg:GPG für OpenPGP:/usr/bin/gpg2
gpg-agent:GPG Agent:/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:/usr/lib/gnupg2/scdaemon
[snip]
Run Code Online (Sandbox Code Playgroud)

但这是不可用的:

$ /usr/lib/gnupg2/scdaemon
bash: /usr/lib/gnupg2/scdaemon2: No such file or directory
Run Code Online (Sandbox Code Playgroud)

安装 scdaemon

快速查询apt-cache显示 Debian 退出scdaemon 了该gnupg2软件包,可能是因为它引入了一堆 GnuPG 否则不会有的新依赖项:

Package: scdaemon
Source: gnupg2
Version: 2.1.10-3
Installed-Size: 538
Maintainer: Debian GnuPG Maintainers <pkg-gnupg-maint@lists.alioth.debian.org>
Architecture: amd64
Replaces: gpgsm (<< 2.0.18-2)
Depends: gnupg-agent (= 2.1.10-3), libassuan0 (>= 2.2.0), libc6 (>= 2.15),
  libgcrypt20 (>= 1.6.1), libgpg-error0 (>= 1.14), libksba8 (>= 1.2.0),
  libnpth0 (>= 0.90), libusb-0.1-4 (>= 2:0.1.12)
Breaks: gpgsm (<< 2.0.18-2)
Description-en: GNU privacy guard - smart card support
 GnuPG is GNU's tool for secure communication and data storage.
 It can be used to encrypt data and to create digital signatures.
 It includes an advanced key management facility and is compliant
 with the proposed OpenPGP Internet standard as described in RFC4880.
 .
 This package contains the smart card program scdaemon, which is used
 by gnupg-agent to access OpenPGP smart cards.
Run Code Online (Sandbox Code Playgroud)

安装它可以sudo apt-get install scdaemon解决问题。