From d70336f37c3cc6f19d85a5fb4852de25c2ee82b9 Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Thu, 13 Nov 2014 21:46:02 +0100 Subject: [PATCH 1/3] limit the amount of time ssh-agent keeps a key (default: 1h) --- nixos/modules/programs/ssh.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix index ee9cb81a027f..c1c1582ed787 100644 --- a/nixos/modules/programs/ssh.nix +++ b/nixos/modules/programs/ssh.nix @@ -59,6 +59,14 @@ in ''; }; + agentTimeout = mkOption { + type = types.string; + default = "1h"; + description = '' + How long to keep the private keys in memory. + ''; + }; + package = mkOption { default = pkgs.openssh; description = '' @@ -99,7 +107,7 @@ in wantedBy = [ "default.target" ]; serviceConfig = { ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent"; - ExecStart = "${cfg.package}/bin/ssh-agent -a %t/ssh-agent"; + ExecStart = "${cfg.package}/bin/ssh-agent -t ${cfg.agentTimeout} -a %t/ssh-agent"; StandardOutput = "null"; Type = "forking"; Restart = "on-failure"; From d57110fabc92116e8a47fc708580fe1a1d10d98e Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Sat, 15 Nov 2014 12:13:19 +0100 Subject: [PATCH 2/3] ssh-agent: make key timeout optional --- nixos/modules/programs/ssh.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix index c1c1582ed787..6b7295722485 100644 --- a/nixos/modules/programs/ssh.nix +++ b/nixos/modules/programs/ssh.nix @@ -63,7 +63,7 @@ in type = types.string; default = "1h"; description = '' - How long to keep the private keys in memory. + How long to keep the private keys in memory. Use null to keep them forever. ''; }; @@ -107,7 +107,10 @@ in wantedBy = [ "default.target" ]; serviceConfig = { ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent"; - ExecStart = "${cfg.package}/bin/ssh-agent -t ${cfg.agentTimeout} -a %t/ssh-agent"; + ExecStart = + "${cfg.package}/bin/ssh-agent " + + optionalString (cfg.agentTimeout != null) ("-t ${cfg.agentTimeout} ") + + "-a %t/ssh-agent"; StandardOutput = "null"; Type = "forking"; Restart = "on-failure"; From 2fd7e5f39d8fd18646bba2fa7fbf69baf21a86ff Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Sat, 15 Nov 2014 12:33:01 +0100 Subject: [PATCH 3/3] ssh-agent: use types.nullOr --- nixos/modules/programs/ssh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix index 6b7295722485..c9bfe2fe0f70 100644 --- a/nixos/modules/programs/ssh.nix +++ b/nixos/modules/programs/ssh.nix @@ -60,7 +60,7 @@ in }; agentTimeout = mkOption { - type = types.string; + type = types.nullOr types.string; default = "1h"; description = '' How long to keep the private keys in memory. Use null to keep them forever.