gpg: 导入失败密钥 xxxxxxxx: 没有有效的用户 ID

gpg: 导入失败密钥 xxxxxxxx: 没有有效的用户 ID

我在 gpg (GnuPG) 1.4.2 上导入公钥时出现此错误

gpg: armor header: Version: GnuPG v2.0.14 (GNU/Linux)
gpg: pub  xxxxx/xxxxxxxx 2012-05-25  abcd xyz <[email protected]>
gpg: DSA requires the use of a 160 bit hash algorithm
gpg: DSA requires the use of a 160 bit hash algorithm
gpg: key xxxxxxxx: invalid self-signature on user ID "abcd xyz <[email protected]>"
gpg: DSA requires the use of a 160 bit hash algorithm
gpg: DSA requires the use of a 160 bit hash algorithm
gpg: key xxxxxxxx: invalid subkey binding
gpg: key xxxxxxxx: skipped user ID "abcd xyz <[email protected]>"
gpg: key xxxxxxxx: skipped subkey
:pg: key xxxxxxxx: no valid user IDs
gpg: this may be caused by a missing self-signature
gpg: Total number processed: 1
gpg:           w/o user IDs: 1

即使在我的选项文件中添加了“allow-non-selfsigned-uid”,gpg 仍然说使用此密钥加密不安全。在导出公钥时我们必须做什么来解决这个问题吗?

答案1

也可能是版本冲突:密钥(源自 gpg v2.x)可能具有旧 1.4 系列 gpg 无法理解的某些功能。

(如果您尝试向 2.1 版之前的 gpg 提供可在 2.1 版或更新版本中创建的椭圆曲线密钥,也会出现类似的误导性错误消息gpg --expert。)

答案2

gpg 需要密钥所有者颁发的有效签名 - 这很重要,因为它将用户描述和电子邮件地址绑定到实际公钥;否则,这些信息可能会被任意修改。这个自签名似乎被破坏了,因此 gpg 拒绝使用该密钥。

答案3

gpg (GnuPG) 1.xx 仅支持最高 DSA1024。不过,任何 RSA 密钥都可以使用。

当尝试导入 DSA2048 密钥(其中 RSA2048 甚至 RSA4096 都可以工作)时,将抛出错误“gpg:DSA 需要使用 160 位哈希算法”。


检查公钥是否符合 1.x 版本:

> gpg --list-packet {key.pub}|grep -A2 "public sub key packet"

:public sub key packet:
        version 4, algo 1, created 1560364275, expires 0
        pkey[0]: [2048 bits]

命令将在第一行返回 Algo,其中生成密钥时可以选择这里列出的 2 个(参考:公钥算法)。


ID算法

== =========

1-RSA(加密或签名)[HAC]

17 - DSA(数字签名算法)[FIPS186] [HAC]


如果返回 algo 17,则 gpg(GnuPG)1.xx 将仅支持最多 1024 位(使用上述命令返回的第二行)。

请注意,gpg(GnuPG)2.xx 支持任何大小的任何算法

答案4

我最近遇到过一个案例,希望对从谷歌过来的人有所帮助。它类似于https://superuser.com/a/1599406/151093但错误消息仅显示“密钥 xxxxxxxx:没有有效的用户 ID”,而没有其他错误暗示“密钥格式错误”。

如果目标 GPG 二进制文件不支持密钥类型然后你就会得到那个错误。我在现代安装上生成一个新密钥,并将公钥导出到 CentOS 机器,该机器有一个古老的 GPG 安装。将密钥从默认的“ECC”切换到“RSA

相关内容