mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-22 00:41:12 +01:00
ssh-agent: Allow other systemd units access to $SSH_AUTH_SOCK
If another systemd unit wants to talk to the ssh-agent service, they need to know the SSH_AUTH_SOCK variable to do so.
This commit is contained in:
parent
43e205606a
commit
0467d026ce
5 changed files with 16 additions and 7 deletions
|
|
@ -86,11 +86,18 @@ in
|
||||||
Description = "SSH authentication agent";
|
Description = "SSH authentication agent";
|
||||||
Documentation = "man:ssh-agent(1)";
|
Documentation = "man:ssh-agent(1)";
|
||||||
};
|
};
|
||||||
Service.ExecStart = "${lib.getExe' cfg.package "ssh-agent"} -D -a %t/${cfg.socket}${
|
Service = {
|
||||||
lib.optionalString (
|
ExecStart = "${lib.getExe' cfg.package "ssh-agent"} -D -a %t/${cfg.socket}${
|
||||||
cfg.defaultMaximumIdentityLifetime != null
|
lib.optionalString (
|
||||||
) " -t ${toString cfg.defaultMaximumIdentityLifetime}"
|
cfg.defaultMaximumIdentityLifetime != null
|
||||||
}";
|
) " -t ${toString cfg.defaultMaximumIdentityLifetime}"
|
||||||
|
}";
|
||||||
|
ExecStartPost = "${pkgs.writeShellScript "update-ssh-agent-env" ''
|
||||||
|
if [ -z "$SSH_AUTH_SOCK" ]; then
|
||||||
|
${pkgs.dbus}/bin/dbus-update-activation-environment --systemd "$@"
|
||||||
|
fi
|
||||||
|
''} SSH_AUTH_SOCK=%t/${cfg.socket}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ WantedBy=default.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@openssh@/bin/ssh-agent -D -a %t/ssh-agent/socket
|
ExecStart=@openssh@/bin/ssh-agent -D -a %t/ssh-agent/socket
|
||||||
|
ExecStartPost=/nix/store/00000000000000000000000000000000-update-ssh-agent-env SSH_AUTH_SOCK=%t/ssh-agent/socket
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SSH authentication agent
|
Description=SSH authentication agent
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/systemd/user/ssh-agent.service \
|
$(normalizeStorePaths home-files/.config/systemd/user/ssh-agent.service) \
|
||||||
${./basic-service-expected.service}
|
${./basic-service-expected.service}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ WantedBy=default.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@openssh@/bin/ssh-agent -D -a %t/ssh-agent -t 1337
|
ExecStart=@openssh@/bin/ssh-agent -D -a %t/ssh-agent -t 1337
|
||||||
|
ExecStartPost=/nix/store/00000000000000000000000000000000-update-ssh-agent-env SSH_AUTH_SOCK=%t/ssh-agent
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SSH authentication agent
|
Description=SSH authentication agent
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/systemd/user/ssh-agent.service \
|
$(normalizeStorePaths home-files/.config/systemd/user/ssh-agent.service) \
|
||||||
${./timeout-service-expected.service}
|
${./timeout-service-expected.service}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue