Skip to content

sops can't decrypt when only provided an SSH key path #695

@3ulalia

Description

@3ulalia

I've managed to pare my config down to the following minimal setup:

sops.defaultSopsFile = inputs.self.outPath + "/secrets/secrets.yaml";
sops.age.sshKeyPaths = ["/home/eulalia/.ssh/id_ed25519"];
sops.secrets."passwords/eulalia".neededForUsers = true;

Then, in my secrets file (~/flake/secrets/secrets.yaml):

passwords:
  eulalia: $y$thisisafakepasswordhash

And in my sops yaml file (~/.sops.yaml):

keys:
  - &eulalia thepublickeytomySSHkeywhenconvertedtoage
creation_rules:
  - path_regex: secrets/[^/]+\.(yaml|json|env|ini|sops)$
    key_groups:
      - age:
        - *eulalia

Despite this, when I run sops ~/flake/secrets/secrets.yaml it tells me that it is unable to decrypt:

eulalia@sunlanii:~/flake/ > sops secrets/secrets.yaml
Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  thepublickeytomySSHkeywhenconvertedtoage: FAILED
    - | failed to load age identities: failed to open file: open
      | /home/eulalia/.config/sops/age/keys.txt: no such file or
      | directory

The only way to get it to decrypt is to use ssh-to-age to convert my SSH key to an age key and then put it in that location.

Why do I have to put my key there? Isn't setting sops.age.sshKeyPaths enough?

(And yes, I have run sops updatekeys ~/flake/secrets/secrets.yaml a number of times. It has not fixed the issue :p)

I'm presuming that this is the reason behind a related issue I have - namely, when I set my password as described above, it works until I reboot, at which point I'm unable to login. I presume this is because sops is looking for a key file in ~/.config/sops/age/keys.txt despite it not being there.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions