Skip to content

age-plugin-yubikey support #41

Open
@nekowinston

Description

Hi there!

Thanks for this project, I'm trying to add support for the rage YubiKey plugin.

What I've tried so far:

home.nix configuration:

{
  homeage = {
    pkg = pkgs.rage;
    identityPaths = [ "${config.home.homeDirectory}/yubikey.txt" ];
    installationType = "activation";
    file."test" = {
      source = ./data.age;
      symlinks = [ "${config.xdg.configHome}/secret" ];
    };
  };
  # ...other config
}

Create the secret data & create ~/yubikey.txt:

echo "foobar" | rage -i ~/yubikey.txt -e > ~/.config/nixpkgs/data.age
age-plugin-yubikey -i > ~/yubikey.txt

Changes to homeage itself:

diff --git a/homeage/default.nix b/homeage/default.nix
index 45b2ea8..df9130a 100644
--- a/homeage/default.nix
+++ b/homeage/default.nix
@@ -37,7 +37,16 @@ with lib; let
   }: let
     linksCmds = createFiles "ln -sf" path symlinks;
     copiesCmds = createFiles "cp -f" path copies;
+    yubikeyPlugin = pkgs.age-plugin-yubikey + "/bin";
+    pinentry = pkgs.pinentry-gtk2 + "/bin";
+    identity = builtins.head cfg.identityPaths;
   in ''
+    PATH="${yubikeyPlugin}:${pinentry}:$PATH"
+    echo "GETTING IDENTITY FILE CONTENT:"
+    cat ${identity}
+    echo "IDENTITIES PROVIDED: ${identities}"
+    echo "YUBIKEYS CONNECTED:"
+    age-plugin-yubikey -l
     echo "Decrypting secret ${source} to ${path}"
     TMP_FILE="${path}.tmp"
     $DRY_RUN_CMD mkdir $VERBOSE_ARG -p $(dirname ${path})

I added in pinentry-gtk2 after finding str4d/rage#280 and assuming that home.activation is unable to open pinentry-curses.

I'm logging the identity file content, identities provided, and yubikeys connected really only as sanity checks, which produces an output like this:

image


On an unrelated note, on macOS I'm getting an error mounting the secret tmpfs:
Edit: just learned about homeage.mount, my bad.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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