brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ssh-keygen -Y sign lets your SSH key sign any file

Network and access
~/tips/tip-ssh-keygen-y-sign-files

ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file release.tar.gz

Sign and verify files with the SSH key you already have, without setting up GPG.

I suspect many people miss that the SSH key they already have can sign files. No GPG keyring needed, just ssh-keygen -Y.

Sign a file:

ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file release.tar.gz

That writes release.tar.gz.sig. The -n value is a namespace, a label that keeps a signature for one purpose from being reused for another. Use the same one when verifying.

The verifier needs an allowed signers file: an identity, then the public key, one per line.

[email protected] ssh-ed25519 AAAAC3Nza...

Then:

ssh-keygen -Y verify -f allowed_signers -I [email protected] \
  -n file -s release.tar.gz.sig < release.tar.gz

It prints Good "file" signature for [email protected] and exits with 0, so it works in scripts too. Note the file to check comes in on standard input.

The weak spot is the allowed signers file. A signature only proves something if you got that public key through a channel you trust, so do not download it from the same place as the file it is supposed to vouch for.

Further reading: ssh-keygen man page

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link