mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-22 08:06:50 +01:00
feat: add systemd service to register ssh-keys
This commit is contained in:
parent
5c3ec8b073
commit
ad2924a204
1 changed files with 18 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue