$linuxjunkies
>

cosign(1)

Sign and verify container images and artifacts using cryptographic signatures.

UbuntuDebianFedoraArch

Synopsis

cosign [command] [flags]

Description

Cosign is a tool for signing and verifying container images and other artifacts in OCI registries. It uses cryptographic signatures to ensure the authenticity and integrity of container images, enabling secure supply chain verification.

Cosign supports multiple signing methods including keys, Keyless (OIDC-based) signing, and hardware security modules. It integrates with container registries to attach signatures as OCI artifacts alongside images.

Common options

FlagWhat it does
-k, --keyPath to the private key file for signing operations
--keylessUse keyless signing with OIDC provider (Fulcio)
-o, --outputWrite signature to file instead of registry
--registry-referrers-modeUse OCI referrers API for retrieving signatures (oras or registry)
--insecureAllow insecure connections to registry
-r, --recursiveRecursively sign all images in a repository
--certPath to certificate file (for keyless signing)
--chainPath to certificate chain file for verification
--attachmentArtifact type to attach or verify (sbom, attestation, signature)
--verboseEnable verbose logging output

Examples

Generate a new private/public key pair for signing

cosign generate-key-pair

Sign a container image with a private key and push signature to registry

cosign sign --key cosign.key ghcr.io/myuser/myimage:latest

Verify a signed container image using the public key

cosign verify --key cosign.pub ghcr.io/myuser/myimage:latest

Sign an image using keyless signing with OIDC (no local key needed)

cosign sign --keyless ghcr.io/myuser/myimage:latest

Attach an SBOM (Software Bill of Materials) to an image

cosign attach sbom --sbom sbom.json ghcr.io/myuser/myimage:latest

Verify signed attestations attached to a container image

cosign verify-attestation --key cosign.pub ghcr.io/myuser/myimage:latest

Display a tree of all attachments (signatures, SBOMs, attestations) for an image

cosign tree ghcr.io/myuser/myimage:latest

Sign a local file (blob) and save the signature to a file

cosign sign-blob --key cosign.key --output-signature sig.txt artifact.txt

Related commands