-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with systemd-creds #123
Comments
@korfuri Thanks for the thoughtful post. Here are my concerns:
|
Thanks for the reply! Those are very valid points. I wasn't thinking of replacing the secret delivery method, but more of providing users with a choice. Possibly in an extensible way, so there would be other credential delivery methods (e.g. deliver to the machine's keyring, or to the kernel's crypto API). I haven't followed the Darwin proposals but maybe these are two similar needs (different secret delivery mechanisms) and a common API could help there as well? Your point 2 is indeed correct (AFAIK, systemd doesn't manage users... yet ;) ) which feeds into why this can't replace every secret delivery. To your third point, it's precisely because systemd-creds doesn't support asymmetric cryptography that I want to use agenix in conjunction with it :) But yeah, I'd like agenix to deliver the secrets to a pipe, and then let systemd-creds take it from there. In terms of how these two can interface together in practice, see this line: https://github.com/korfuri/agenix-systemd/blob/abf6c934ba3af682a838670e51357ffa0069f9c0/modules/age.nix#L26 I don't want to be pushy or anything, I'm also happy to use my own fork, but if you have some thoughts on a "secret delivery API" for the output side of agenix, I'm also happy to contribute to the discussion. |
Hello, I am very new to agenix and systemd-creds. What benefits would there be for using |
Using LoadCredential in a non-encrypted way also works. It does bring most of the direct benefits of using systemd-creds (mostly: automatic management of secret permissions). However, I'd like to steer NixOS modules to use The main benefit from standardizing on the Encrypted version, even if it adds some complexity, is that this lets us change the off-host secret distribution story without changing the on-host one. E.g., if modules all rely on LoadCredentialEncrypted we have a path to using systemd-creds without age once systemd-creds implements public-key crypto support (it is in systemd's TODO). Age is a great option for off-host secret distribution but it's likely to run into some hurdles for the enterprise use-case, where things like Hashicorp Vault would probably work better (or at least just have a better sales pitch). We'll need to standardize how NixOS modules accept credentials, and so I'd rather have it be on the encrypted variant rather than the unencrypted one. |
I'm working on something similar right now that would benefit from a feature where agenix could be instructed to create a transparently re-encrypted (with I'm not completely sure yet how the process of "place unencrypted file on the host's file system" -> "pack that re-encryted secret into the initrd" should go, but I feel that agenix would be a pretty good place for the transparent re-encryption to take place. |
Hi all, I've been experimenting with agenix and other secret distribution mechanisms trying to find the one I like the most. I'm quickly converging on agenix as my top choice! One thing I've noticed is that ~nothing in the NixOS world seems to make use of systemd's credentials management feature. It's quite new so that's probably why.
The full doc on that feature is at https://systemd.io/CREDENTIALS/ and the tl;dr is that you can encrypt secrets to a host-specific key (TPM-backed, if a TPM2 is available) and let systemd manage the decryption and distribution of secrets to units. This offers some improvements over agenix's current method of distributing secrets (decrypting them all at activation time and chown/chmoding them to their intended user):
It does have a significant downside: no support for "user" (as in,
isNormalUser = true
users) secrets. This can be hacked around, in that you could run "system" oneshot services as root to copy creds to a user's homedir, I guess.I have a prototype implementation of a fork of agenix that does this. Essentially, it's creating oneshot units for each secret that basically do
age --decrypt -o - | systemd-creds encrypt - $TMP_FILE
at https://github.com/korfuri/agenix-systemd in case anyone is interested in this approach. I could have made it a tentative PR for agenix but I found that it made the agenix API quite cumbersome and that a prototype was probably a better way to start the discussion and gauge interest.A couple notes to address some questions you may have:
| systemd-creds encrypt
in the existing agenix implementation, unfortunately activation scripts run before systemd starts, which means systemd-creds can't talk to the bit of systemd that has access to the host key.LoadCredentialEncrypted=
orSetCredentialEncrypted=
so using this at scale will require some hacking with service configs. If your service supports environment variable expansion that's quite easy (secret foo is at$CREDENTIAL_DIRECTORY/foo
), but if it doesn't you probably need to pre-process the config or something.$CREDENTIAL_DIRECTORY
changes so you can't just hardcode it somewhere either.I'm interested in what people think about this. I'm not entirely sold - the main benefit to me is pretty immaterial tbh, it's just that it's nice to use systemd idiomatically. Would you use this? Would it make sense to try to make this a native agenix feature? Did I miss something glaringly obvious and my approach is broken?
Thanks!
The text was updated successfully, but these errors were encountered: