跳到主要内容
ecdsa.com
OpenSSH ssh-keygen -Y verify (SSHSIG)SSH

错误信息

Signature verification failed: incorrect signature

也可能输出为

  • Couldn't verify signature: namespace does not match
  • Could not verify signature.

如果允许的签名者文件中没有为这个密钥列出该主体(principal),只会报出“Could not verify signature.”(前面没有详细信息行)。

OpenSSH ssh-keygen -Y verify (SSHSIG) — also used by Git for SSH-signed commits

含义

`ssh-keygen -Y verify` 检查了一个 SSHSIG 签名,密码学验证失败:从标准输入读取的数据与签名的数据并不完全相同,或者签名是由另一个密钥生成的。SSH 签名还会绑定一个命名空间(`file`、`git`、`email`……);在不同命名空间下验证签名,会在密码学检查之前就报出“namespace does not match”。每次失败之后都会跟着一行“Could not verify signature.”。

原因

修复方法

  1. 1.

    用正确的命名空间验证原始字节

    把原始文件通过管道传给 `ssh-keygen -Y verify`,并使用签名时的命名空间。`find-principals` 会显示该密钥对应哪个身份。

    bash
    # Verify exactly the bytes that were signed, with the namespace used at signing time
    ssh-keygen -Y verify -f allowed_signers -I release@example.com -n file -s release.txt.sig < release.txt
    # Which principal does the allowed_signers file map this signature's key to?
    ssh-keygen -Y find-principals -f allowed_signers -s release.txt.sig
  2. 2.

    把密码学验证与信任分开

    `check-novalidate` 会验证签名,但不查询允许的签名者文件。如果它通过了,问题出在身份映射上;如果它失败了,就是数据或签名有误。

    bash
    ssh-keygen -Y check-novalidate -n file -s release.txt.sig < release.txt   # signature valid at all (no trust check)?

相关错误

浏览完整的签名错误库