Contents
SSH key can be used outside of login
Modern OpenSSH provides functions for signing and verifying files in the SSHSIG format via ssh-keygen. You do not need to create an OpenPGP identity for this operation. However, the result is not an OpenPGP signature, and the recipient needs to support it. The common word signature does not guarantee compatibility between different formats.
First, consider a separate signing key. Using a single key for both login and file distribution combines the two purposes and makes it difficult to rotate or break trust later. For the demonstration, we will create a new test identity in an empty working directory. Do not overwrite existing keys or a raw file with the same name.
Prepare the tool and a new test key
ssh -V
ssh-keygen -t ed25519 -f ./podpisovy-klic -C "podpis-test"The tool will ask for a passphrase for the private part; for real-world use, choose a strong unique phrase. This will create a private signature-key file and a public signature-key.pub file. Keep the private part protected and do not send it to the recipient for verification purposes. Ed25519 in this example is not a post-quantum algorithm.
If your local ssh-keygen does not support the -Y switch, you need a compatible implementation or a supported upgrade. The mere presence of the ssh command on your system is not proof of all modern features. For hardware or hybrid keys, verify specific support for the signing operation; this example does not promise universal use for every key type.
Sign the exact document with namespace
ssh-keygen -Y sign -f ./podpisovy-klic -n file ./dokument.txtA separate signature document.txt.sig is created. The namespace file defines the intended context of the signature and must match during verification. It is not a file path or secret value. Your own integration system may use a different pre-agreed namespace; do not randomly take a value from an unrelated protocol.
The selected data is being signed, so complete the document content first. Renaming usually does not change the bytes, but resaving in a different encoding or converting line endings does. Give the recipient the form you just signed and its signature. Also check the size and location if you have multiple copies with similar names.
Write the recipient's trust in allowed_signers
Authentication requires a trusted public key and a rule that binds it to the expected identity. The allowed_signers file can contain the signer identifier and a public part, or restrictive options. The example creates a row for the identity vydavatel@example.invalid and restricts it to the namespace file.
# Spusťte jen pro testovací veřejný klíč v tomto adresáři.
printf 'vydavatel@example.invalid namespaces="file" %s\n' "$(cat ./podpisovy-klic.pub)" > ./allowed_signers
ssh-keygen -lf ./podpisovy-klic.pubIn production, a public key should not be accepted without verification just because it came with a file. Compare the full fingerprint to a trusted source and determine the authorized signing purpose. The identifier in allowed_signers is not an automatically verified email address or legally confirmed person; it is part of your local trust policy.
Perform full verification
ssh-keygen -Y verify -f ./allowed_signers -I vydavatel@example.invalid -n file -s ./dokument.txt.sig < ./dokument.txtThe verifier reads the document from standard input and the signature from the specified file. The identity, namespace, and authorized key must match. Observe the result and return status of the process. The check-novalidate command has a different purpose: checking cryptographic consistency without a complete authorized identity rule is not equivalent to this operation.
A positive result confirms the binding to the key allowed by your rule. It does not guarantee the integrity of the program, the current release, or the accuracy of the information in the document. If you measure and sign an old installation package, a valid signature will not make it a new security update.
Test negative case and transmission
Create a copy of the document, change its contents, and verify it against the original signature. The check must fail. Also verify the incorrect identity or namespace to confirm that your workflow does not ignore context. Do not test by modifying the only original copy of an important document.
When handing over, send the data, a separate signature, and instructions for the approved public key. The textual form of the signature must not be confused with the content of the document. Do not manually convert it to OpenPGP: the format has its own structure and rules. The recipient can use another compatible tool, but it needs real SSHSIG support.
Rotation and long-term use
Keep a record of where the signing key is trusted. Removing it from the server's authorized_keys does not change the allowed_signers file on the recipients. Therefore, address all relevant authorization lists, revocation mechanisms, and notifications in the event of a leak. Expiration and revocation require a specific policy, not just deleting a local private file.
- The signature was created over the final form of the data.
- The recipient has a verified public fingerprint and the correct namespace.
- Authentication includes identity and its authorization.
- The negative test for modified data failed.
- There is a plan for trust revocation and key replacement.
SSHSIG is a practical option for environments that already know how to securely manage SSH keys. However, its simple commands do not eliminate the need to establish trust. The biggest part of proper authentication is whether the recipient has actually authorized the expected key for the expected purpose.
Frequently asked questions
Is SSHSIG compatible with OpenPGP?
This is not the same format. The recipient needs a tool with SSHSIG support.
What does namespace mean?
It separates the purposes of the signature and must match both signing and verification.
Is check-novalidate enough to verify the publisher?
No. Identity authorization-free checking does not replace verification against trusted allowed_signers.
Detailed documentation
OpenSSH: ssh-keygen, SSHSIG and allowed_signers →