$linuxjunkies
>

sops(1)

sops is a simple tool for managing secrets in YAML, JSON, ENV, INI and BINARY files using encryption.

UbuntuDebianFedoraArch

Synopsis

sops [OPTIONS] [FILE]

Description

sops encrypts and decrypts data in configuration files using various key management services (AWS KMS, GCP KMS, Azure Key Vault, PGP, age) or local keys. It works transparently with YAML and JSON, encrypting only the values while preserving file structure and comments.

You can edit encrypted files directly without decrypting them first, and sops will handle encryption/decryption automatically. It's commonly used in DevOps workflows to manage secrets in Git repositories, Kubernetes configurations, and infrastructure-as-code tools.

Common options

FlagWhat it does
-e, --encryptencrypt a file
-d, --decryptdecrypt a file and print to stdout
-r, --rotaterotate data key with master key(s)
-i, --in-placewrite encrypted output back to the input file
--aws-profile PROFILEuse specific AWS profile for KMS operations
--kms ARNuse AWS KMS key by ARN; can be specified multiple times
--pgp KEY_IDencrypt with PGP key; can be specified multiple times
--age RECIPIENTencrypt with age public key
-d, --output-type FORMAToutput format: json, yaml, dotenv, binary (default: same as input)
--input-type FORMATspecify input file format explicitly
-c, --config CONFIG_FILEpath to .sops.yaml configuration file
--show-metadatainclude sops metadata in output

Examples

encrypt secrets.yaml with default KMS key and save to secrets.yaml.enc

sops -e secrets.yaml > secrets.yaml.enc

open and decrypt an encrypted file in your default editor ($EDITOR)

sops secrets.yaml.enc

decrypt and print file contents to stdout (view without editing)

sops -d secrets.yaml.enc

encrypt secrets.yaml in-place, overwriting the original file

sops -e -i secrets.yaml

encrypt config.yaml using a specific AWS KMS key

sops -e --kms arn:aws:kms:us-east-1:123456789012:key/12345678 config.yaml

decrypt YAML file and output as JSON

sops -d -o json secrets.yaml > secrets.json

rotate the data key in secrets.yaml with current master keys

sops -r -i secrets.yaml

encrypt file with multiple PGP keys for team sharing

sops -e --pgp '[email protected]' --pgp '[email protected]' secrets.yaml

Related commands