home/ssh: enable control master sockets

This commit is contained in:
2025-03-31 17:31:42 +02:00
parent 66abe25322
commit 24572e5055

View File

@@ -1,4 +1,8 @@
{ config, ... }:
{ config, pkgs, ... }:
let
runtimeDir = "/run/user/${toString config.home.uid}";
controlMastersDir = "${runtimeDir}/ssh-controlmasters";
in
{
imports = [
./home.nix
@@ -16,5 +20,22 @@
config.sops.secrets."ssh/secret-config".path
"mutable_config"
];
controlMaster = "auto";
controlPersist = "10m";
controlPath = "${controlMastersDir}/%r@%h:%p";
};
systemd.user.services."ssh-create-controlmasters-dir" = {
Install.WantedBy = [ "default.target" ];
Unit = {
Description = "Create directory to store SSH control master sockets";
ConditionPathExists = "!${controlMastersDir}";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.coreutils}/bin/mkdir ${controlMastersDir}";
Restart = "on-abort";
};
};
}