What does HackerNews think of sops?

Simple and flexible tool for managing secrets

Language: Go

#1 in Azure
#3 in Security
Some folks use tools like https://github.com/mozilla/sops to store most secrets (besides the sops key, of course) in source control. Of course, you aren't committing the cleartext but if the repo gets published you should probably rotate your keys just to be safe...
My experience is similar to the other comments here:

- A combination of sops[1] and AWS Parameter Store might be a good candidate for (4)

- (5) can be solved with AWS SSO / OIDC (also: platforms that offer OIDC, usually support that feature for free, and a variety of them can be configured via Terraform)

- For (6), there are solutions like Atlantis[2] for Terraform, but I am not familiar with alternatives for Pulumi and Ansible. Might be a good idea to spend some time and build a pipeline with whichever CI/CD platform you are using (bonus: GitHub Actions supports OIDC auth with AWS as an IAM role[3], no secrets nor credentials required!)

- For (7), you can create a separate AWS account and manage it with AWS Organizations (or not)

- For (8), 1pass[4] for any credentials that requires username/password combo (non-tech/breakglass account). Groups can be created to limit certain credentials to subsets of users

[1] https://github.com/mozilla/sops

[2] https://www.runatlantis.io/docs/repo-level-atlantis-yaml.htm...

[3] https://docs.github.com/en/actions/deployment/security-harde...

[4] https://support.1password.com/custom-groups/

I ran into this recently when using https://github.com/mozilla/sops. It worked pretty nicely and as a tool was quite easy to get started with.
I like SOPS [0], but it might be a bit heavyweight. You can also use team versions of password managers for simpler tasks.

[0] https://github.com/mozilla/sops

You might also find sops more user friendly for teams

I never understand why people go all in on cloud based password stores or identify for that manner

https://github.com/mozilla/sops

I recommend against with using secrets managers as opposed to config files for storing configuration. Ideally, your configuration is versioned and code-reviewed. Config files are optimal. Even secrets used by your deployment should be stored in configuration - encrypted, of course. The benefit of versioned configuration files, secrets included, cannot be overstated.

You can encrypt sensitive configuration fields with tools like `mozilla/sops` [1], which will reach out to your KMS or secrets manager of choice to encrypt/decrypt sensitive fields on the fly.

This way, you are minimizing the splitting of state across secrets managers and your code. Your configuration is stored at code, code reviewed, and versioned, which has devops and security benefits of its own.

[1]: https://github.com/mozilla/sops

For encrypted secrets in git I'd suggest looking at sops and password store:

https://github.com/mozilla/sops

https://github.com/android-password-store/Android-Password-S...

Both are extremely useful secrets oriented git tools with support for things like PGP encryption. Both will encrypt with multiple keys too, making sharing relatively easy. The android pass app even manages SSH keys for pushing and pulling. There may be good inspiration in those repos, or even code you can borrow.

Also, thanks so much for making this: it is elegant and lovely. Keep it up!

Mozilla SOPS, a tool for encrypting secrets for storage in source control systems, lets you encrypt secrets using the Shamir Sharing Threshold. You can use (and mix and match!) keys stored in of the first-party cloud secrets managers (AWS Secrets Manager, GCP KMS, Azure Key Vault), Hashicorp Vault, GnuPG, or Age.

Various IaC ecosystems have integrations for it. It's probably the best way to store secrets for Nix-based deployments, and there are also docs and integrations that pair it up with Kubernetes and Terraform.

Idk how many companies are really using keygroups, though. Probably in some of them, the repos are public and can tell you that.

https://github.com/mozilla/sops

i’ve used `pass` for 4-ish years now. i stopped last month. the interactions between pass and gpg-agent are too opaque for someone who’s not a regular PGP user. what happens when i let my PGP key expire? what’s the right way to share passwords between multiple machines — can i just clone the ~/.gnupg folder, do i need to `export` and then `import` the keys? should i create subkeys for each machine?

i want my password manager to be decently transparent, because if i misunderstand its failure modes that’s a big deal.

anyway, i’m using SOPS now [1]. it comes with a different set of tradeoffs (doesn’t integrate with keyrings quite as well as GPG does), but it’s way more transparent and pluggable. i generate distinct pubkey/privkey pairs per logical user and i can grant any subset of keys access to specific secrets. so e.g. my desktop and laptop can decrypt my banking secrets, but my phone cannot. i have a nightly backup cronjob which has to run unattended: i encode my Backblaze API key to the `duplicity` user’s privkey, and can safely check the encoded key into public repos and such. it’s simple and easy to grok. more so than pass, IMHO.

1: https://github.com/mozilla/sops

Covered by the guide: see https://github.com/drduh/YubiKey-Guide#using-keys and look for "Encrypt a message to your own key".

Also, sops (https://github.com/mozilla/sops) works with gpg and so with Yubikeys.

Yes it is, and they are awesome. git-crypt[0] is a godsend for smaller projects (and maybe larger ones if permissions are granular enough) -- way simpler than sops[1] and other alternative, with native integration via git filters (smudge). I use it on a ton of projects.

[0]: https://www.agwa.name/projects/git-crypt/

[1]: https://github.com/mozilla/sops

Sidenote: I really like the cookie consent form on this site. It's unobtrusive, clear, opt-out by default and the highlighted and only button is "Continue to site". And it even has a built-in GDPR request form! Bravo to https://www.clym.io/

Nice article, covers the basics well. Credential files seem like simplest way to go and are secure enough for most local uses. For anything more involved a secrets manager is probably required. I've been using Linux for a long time and hadn't heard about `keyctl`, thanks for mentioning it. A more flexible solution might be https://github.com/mozilla/sops

If you are going to put creds in git, at least use sops.

https://github.com/mozilla/sops

sops is a great tool for version-controlled secrets - plaintext keys and encrypted values using remote KMS to do the encryption. https://github.com/mozilla/sops
We use `sops`[1] to do this and it works really well.

There is a Google Cloud KMS keyring (for typical usage) and a GPG key (for emergency/offline usage) set up to handle the encryption/decryption of files that store secrets for each application's deployment. I have some bash scripts that run on CI which are essentially just glorified wrappers to `sops` CLI to generate the appropriate `.env` file for the application, which is put into the container by the `Dockerfile`.

Applications are already configured to read configuration/secrets from a `.env` file (or YAML/JSON, depending on context), so this works pretty easily and avoids depending on secrets being set in the `ENV` at build time.

You can also, of course, pass any decrypted values from `sops` as arguments to your container deployment tool of choice (e.g. `helm deploy foo --set myapp.db.username=${decrypted_value_from_sops}`) and not bundle any secrets at build time at all.

[1] https://github.com/mozilla/sops

I especially like the security parts. SOPS integration that lets you store encrypted credentials and the like in YAML files seems like such a cool way to get the benefits of GitOps without sacrificing security.

Edited to add link to https://github.com/mozilla/sops and to also mention my surprise at that Mozilla is behind SOPS. :)

The "Store secrets safely" section seems to propose three alternative solutions: store secrets encrypted in Git, expose secrets to applications with environment variables, and encrypt secrets with KMS. But those are solutions to different problems. You can use all three.

For example you can use sops (https://github.com/mozilla/sops) to store encrypted secrets in Git, using AWS/GCP KMS to encrypt/decrypt them (or encrypt/decrypt the encryption key), and have infrastructure automation that gets the secrets from sops and exposes them to applications as environment variables.

https://github.com/mozilla/sops is quite good to store encrypted secrets. Because the decryption key is stored in a KMS the secret access can be revoked any time.
When managing/deploying code we use SOPS (Secrets OPerationS) https://github.com/mozilla/sops

For standard password style secrets used by Ops, we use Team Password Manager. Which we chose about 5 years ago because it was self-hosted, the database was encrypted, and it had fantastic audit capabilities.

Curious about why you're using SOPS [1] instead of say, hashicorp vault or AWS/GCP's integrated keystores or git-crypt, etc?

[1] https://github.com/mozilla/sops

If I'd decide to keep the secrets in the repo, I would have them encrypted with e.g. GnuPG and put a key in the CI's environment variables.

    # Something in lines of this...
    # TODO: Make sure the keyrings are on tmpfs, too.
    # Something like export GNUPGHOME="/run/gnupg" && mkdir -p "$GNUPGHOME"
    gpg2 -v --import <(echo "$GPG_PRIVATE_KEY")
    gpg2 --decrypt --output /run/secrets/credentials.json lib/credentials.json.gpg
    ln -s /run/secrets/credentials.json lib/credentials.json
For this I have to trust the CI, of course... And given that CI jobs run in isolated environments but on a shared hosts, there could be a way for malicious party to access the data. IIRC, there were some exploits that break out of Docker.

If you host in the cloud that offers a KMS (AWS, GCP, Azure), a slightly advanced alternative is SOPS: https://github.com/mozilla/sops (you can use that with GnuPG as well)

Vault looks great, but I always balk at the operational overhead. Also the cost is significant. I'm at a tiny org, though.

For smaller orgs and projects, Mozilla Sops is really great:

https://github.com/mozilla/sops

It encrypts your secrets at rest using Google KMS, Amazon KMS, and various other cloud provider key services. You can then put those secrets into your code repository, cloud file storage, etc. and give your build pipeline a service account with the ability to decrypt the secret files.

Scales like crap, but is quick and dirty when you need it.

Not sure I understand your use case but does this help?

https://github.com/mozilla/sops

For my k8s secrets I've been using sops: https://github.com/mozilla/sops

It supports GCP/AWS KMS, so as long as my GCP user account can read the keychain, I can decrypt the secret. Very simple and does the job.

If you're comfortable with using KMS already, I recommend checking out SOPS: https://github.com/mozilla/sops

It can be versioned if you use git, access controlled via the KMS access privileges, and easily plugs into other tools because it uses YAML. Simplicity is the killer feature.

Anything secret involves a master key. If you don't trust AWS, then you need to supply your own master key. But for most setup, IMO, you should just let AWS handle the key management, and you use role to decrypt. Rotation is a big deal though. For server, SSH key can be encrypted in KMS and we either completely replace the box, or we rotate one box at a time. For DB servers, it's important to choose a DB that can stream data to a new box with as little impact as possible (or allows replication). But these takes time to develop (I can't use container to host DB or critical applications because the network performance, at least a year ago).

BTW Mozilla's sops [1] is quite interesting. I've been testing this for a while now.

[1]: https://github.com/mozilla/sops

I wrote https://github.com/mozilla/sops to manage secrets in our deployments, and also use it as my personal password store, to encrypt a file stored in a private git repo.
I wrote some of my thoughts on the topic, and the primary motivation behind SOPS [1] (which uses PGP and KMS): https://jve.linuxwall.info/blog/index.php?post/2015/10/01/In...

The initial trust problem boils down to trusting the API that controls the provisioning of your infrastructure. Failing that, you have to ask a human to manually authorize new nodes to retrieve secrets (that's how puppet approves new agent certs).

[1] https://github.com/mozilla/sops

My colleague Guillaume Destuynder wrote that blog post. We still use CryptoSticks at Mozilla, with sops[1] to securely store backup keys of some of our secrets files.

[1] https://github.com/mozilla/sops

An alternative approach, if you don't want to be 100% tied to KMS, is https://github.com/mozilla/sops . It uses KMS, but also PGP, and potentially anything that comes up in the future.