跳到主要内容
ecdsa.com

SSH 签名验证工具

粘贴 .sig 文件和被签名的文本(或选择文件),或者粘贴原始的 Git 提交或标签。添加仓库使用的 allowed_signers 文件,或者只添加预期的公钥:验证工具会检查签名、签名所针对的命名空间,以及该密钥在当时是否有权以该身份签名。

100% 本地运行——所有操作都在你的浏览器中完成,不会向任何服务器发送数据

来源:示例由 ssh-keygen -Y sign(OpenSSH 10)和 git 2.47 使用本站公开的测试密钥签名——tools/ssh-signature-verifier/fixtures/sshsig.json

ssh-keygen -Y sign 生成的 .sig 签名文件,以 -----BEGIN SSH SIGNATURE----- 开头。

在此逐字节计算哈希。
或拖放到此处

在浏览器中读取——文件绝不会上传。

未选择文件时使用。文本框无法保留 Windows 换行符:要逐字节检查,请选择文件。

gpg.ssh.allowedSignersFile 指向的文件:每行一条,先写身份,再写选项和密钥。

OpenSSH 公钥行(.pub 文件),对任意身份均视为可信。

相当于 ssh-keygen -I。留空则列出 allowed_signers 为该密钥接受的所有身份。

留空则使用默认值:Git 对象为“git”,文件为“file”。

What ssh-keygen -Y sign produces

Since OpenSSH 8.0, ssh-keygen -Y sign -f key -n namespace file signs arbitrary data with an SSH key and writes an armored block that starts with -----BEGIN SSH SIGNATURE-----. The format is SSHSIG, specified in PROTOCOL.sshsig in the OpenSSH source. Inside the base64 sits the SSHSIG magic, version 1, the signer's public key, a namespace, the name of the hash algorithm and the signature itself.

The key never signs the file directly. It signs a small structure: the magic, the namespace, a reserved field, the hash algorithm name and the hash of the file — SHA-512 by default, SHA-256 allowed, nothing else. The verifier rebuilds that structure from the file you give it and checks the signature with the key embedded in the block. RSA keys must sign with rsa-sha2-256 or rsa-sha2-512; an ssh-rsa (SHA-1) signature is rejected, as ssh-keygen rejects it. Ed25519, ECDSA P-256/P-384/P-521, the FIDO security-key types (sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com, whose user-presence flags and counter are shown) and SSH certificates are all read.

Why the namespace matters

The namespace says what the signature is for: file for files, git for commits and tags, email for messages, or a name of your own. Because it is inside the signed data, a signature made for one purpose cannot be replayed for another — a signed Git commit cannot pass as a signed release file. The verifier compares it with the namespace you expect (by default git for Git objects and file for everything else) and fails on a mismatch, exactly like ssh-keygen -Y verify -n.

Who may sign: allowed_signers

A valid signature only proves that some key signed. Which keys you trust, and for which identities, is the job of the allowed_signers file described in the ALLOWED SIGNERS section of ssh-keygen(1). Each line names principals (comma-separated patterns such as dev@example.com or *@example.org), optional options and a public key:

allowed_signers
dev@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA… laptop
ci@example.com namespaces="file",valid-before="20271231" ecdsa-sha2-nistp256 AAAA… release
*@example.com cert-authority ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA… company CA

The verifier applies the same rules as ssh-keygen: the identity you enter must match a principal pattern of a line whose key signed; namespaces= limits the purposes; valid-after and valid-before limit the time; and a cert-authority line trusts any SSH certificate that CA signed, provided the certificate is a user certificate, lists the identity among its principals and is valid at the signature time. Leave the identity empty to see every identity the file accepts for the key — what ssh-keygen -Y find-principals prints. If you only have the expected .pub key, paste it instead: it is trusted for any identity. Without either, the signature can be intact but the page says that nothing tells whose key it is — the situation behind Git's “gpg.ssh.allowedSignersFile needs to be configured”.

SSH-signed Git commits and tags

With git config gpg.format ssh, Git signs with ssh-keygen -Y sign -n git. A commit stores the armored signature in a gpgsig header (gpgsig-sha256 in a SHA-256 repository), and the signed bytes are the commit object without that header; a tag carries the signature at the end of its message. Paste the output of git cat-file commit HEAD or git cat-file tag v1.0.0: the verifier splits the object the way Git does, recomputes the object ID, and checks validity windows at the committer or tagger date, as git verify-commit does. A commit signed with OpenPGP is recognised and sent to the OpenPGP inspector; an X.509 (gpgsm or gitsign) signature is named as such. SSH or GPG for commits? The trade-offs are compared in SSH vs GPG commit signing.

The examples were made with OpenSSH 10 (ssh-keygen -Y sign) and Git 2.47 from this site's published test keys, and verified with ssh-keygen -Y verify and git verify-commit when they were generated. SSH keys and certificates themselves are decoded by the SSH key inspector; when to issue SSH certificates instead of listing keys is the subject of SSH certificates vs authorized_keys. For release artifacts signed without long-lived keys at all, see the Sigstore bundle verifier.