diff --git a/modules/base/ssh.nix b/modules/base/ssh.nix index 86dfece..d52e17d 100644 --- a/modules/base/ssh.nix +++ b/modules/base/ssh.nix @@ -1,5 +1,6 @@ { config, + pkgs, username, hostname, lib, @@ -20,6 +21,7 @@ in { mode = "0600"; owner = username; }; + fireproof.home-manager = { home.file.".ssh/id_ed25519.pub".source = ../../secrets/hosts + ("/" + hostname) + "/id_ed25519.pub"; programs.ssh = { @@ -79,5 +81,21 @@ in { settings.KbdInteractiveAuthentication = false; }; + systemd.user.services."add-ssh-keys" = { + description = "Add SSH keys to ssh-agent"; + after = [ "network.target" "ssh-agent.service" ]; + requires = [ "ssh-agent.service" ]; + wantedBy = [ "default.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStartPre='' + ${pkgs.coreutils}/bin/sleep 5 + ''; + ExecStart = '' + ${pkgs.openssh}/bin/ssh-add -q ${config.age.secrets.ssh-key-ao.path} + ''; + }; + }; + users.users.${username}.openssh.authorizedKeys.keys = publicKeys; }