!XLCFfvFhUkYwOMLbVx:nixos.org

agenix

322 Members
age-encrypted secrets for NixOS https://github.com/ryantm/agenix/94 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
26 Mar 2025
@rane:junkyard.systemsrane [they/them]

I think you might be mixing up public and private keys - you need the public key to encrypt, the private key to decrypt. A private key only needs to be present when you are decrypting the existing values. When you are editing or creating secrets, you will need access to at least one private key. Every private key has a corresponding public key, which must be "added" in secrets.nix to have "access" to a secret. A yubikey is just one thing you use, you can use a private key you control with a passphrase for example, instead. As long as the corresponding public key has "access" in secrets.nix to the secret. When it comes to machines, the SSH private key should only ever be present on the machine where the SSH key is being used for SSH, but agenix can also use this as a private key for decrypting secrets. So if you store the public key of a machine which needs access to a secret in the secrets.nix file and give it "access" to a secret, agenix, when running on that destination NixOS machine can decrypt the secrets from the Nix store and then store the decrypted secret as a file under /run which is typically a memory-only filesystem (so they don't persist and need to be decrypted each reboot).

Putting all of this together, if you have a personal private key for admin purposes (i.e., adding and editing secrets), you would give the corresponding public key access to the secrets so the public key is used to encrypt the value. The public keys of any machines (i.e the SSH public key, which ssh-keyscan gives you) are also added as public keys and used for encryption for the secret. Only the machines and users with access to the private key for any of those identities however can actually decrypt the secret. Does that make more sense?

04:21:27
27 Mar 2025
@raijin_:matrix.org@raijin_:matrix.orgimage.png
Download image.png
15:59:19
@raijin_:matrix.org@raijin_:matrix.org

rane [they/them]: thanks so much for your explanations, I think I'm starting to understand. I'm kind of a visual learner, so I diagrammed out my current setup here. Maybe that will shed light on where my misunderstanding lies.

A private key only needs to be present when you are decrypting the existing values

But what public key does this private key correspond to? One of the public keys defined and assigned to the secret in secrets.nix? Or one of the original keys in identityPaths that encrypted the secret?

A yubikey is just one thing you use

So I would have a public key entry in secrets.nix for the YubiKey just as I would for a host?

So if you store the public key of a machine which needs access to a secret in the secrets.nix file and give it "access" to a secret, agenix,

I think I have this part, because when I get a new host (non-server), I generate a new keypair on that machine and add the pubkey to secrets.nix. I then add that key as a target in secrets.nix. (for the secrets defined in user_secrets.nix)? But obviously I'm missing something when trying to rekey my secrets for the new machine, because the operation does not generate new files.

15:59:22
28 Mar 2025
@scottytheengineer:matrix.orgscottytheengineer joined the room.18:16:13
30 Mar 2025
@98765abc:mozilla.org98765abc joined the room.02:13:30
31 Mar 2025
@taw420:matrix.orgtaw420 joined the room.21:13:40
3 Apr 2025
@benjaminsparks:chat.alugha.appBen Sparks joined the room.16:18:24
4 Apr 2025
@divit:matrix.orgdivit joined the room.12:22:35
5 Apr 2025
@tinybronca:sibnsk.net@tinybronca:sibnsk.net left the room.15:41:33
8 Apr 2025
@morbidity3080:deep.fo@morbidity3080:deep.fo joined the room.10:39:18
@morbidity3080:deep.fo@morbidity3080:deep.fo left the room.10:39:52
9 Apr 2025
@codebam:fedora.imSean joined the room.19:06:15
@codebam:fedora.imSeanhttps://github.com/ryantm/agenix/issues/115 where do I get my host ssh key from?19:25:08
@codebam:fedora.imSeanoh, I don't need one19:44:32
10 Apr 2025
@fwam:femdom.solutionsfwam changed their profile picture.19:57:47
11 Apr 2025
@thoughtcrime69:matrix.orgthoughtcrime69 joined the room.14:39:59
@ambroisie:belanyi.fr@ambroisie:belanyi.fr left the room.22:09:34
16 Apr 2025
@wesleyjrz:matrix.orgwesleyjrz joined the room.12:10:05
17 Apr 2025
@mmkaram:matrix.orgmmkaram joined the room.04:29:42
@oneeyed:matrix.orgSam changed their display name from Sam to Sam (away → 5/5).17:17:41
18 Apr 2025
@saik3617:matrix.orgSaik joined the room.16:20:15
@saik3617:matrix.orgSaik

Hello, heres a simple question that I've had a hard time finding an answer to:

is there a way to have a subfolder within secrets/?

I prefer subfoldering--category/secret_name.age--over appending--category.secret_name.age

16:22:34
@eyjhb:eyjhb.dkeyJhb
In reply to @saik3617:matrix.org

Hello, heres a simple question that I've had a hard time finding an answer to:

is there a way to have a subfolder within secrets/?

I prefer subfoldering--category/secret_name.age--over appending--category.secret_name.age

Yes, just create it and use it
16:32:18
@eyjhb:eyjhb.dkeyJhb @Saik https://git.fricloud.dk/fricloud/server-configs/src/branch/main/secrets/secrets.nix#L20 16:33:01
@eyjhb:eyjhb.dkeyJhbAnd then I use it like this https://git.fricloud.dk/fricloud/server-configs/src/branch/main/secrets/default.nix#L616:33:27
@eyjhb:eyjhb.dkeyJhbYou can see all the secrets in that folder as well.16:33:48

Show newer messages


Back to Room ListRoom Version: 6