From c7c469786318da119b053e493128dc0766bfeea6 Mon Sep 17 00:00:00 2001 From: naturallaw77 Date: Sat, 28 Mar 2026 07:54:29 -0500 Subject: [PATCH] updated ssh-bootstrap --- modules/core/ssh-bootstrap.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/core/ssh-bootstrap.nix b/modules/core/ssh-bootstrap.nix index 7ed7b83..1a4e48d 100644 --- a/modules/core/ssh-bootstrap.nix +++ b/modules/core/ssh-bootstrap.nix @@ -3,15 +3,15 @@ let userName = "free"; keyPath = "/home/${userName}/.ssh/factory_login"; + userExists = builtins.hasAttr userName config.users.users; in -{ - # Ensure SSH dirs exist with correct perms +lib.mkIf userExists { + systemd.tmpfiles.rules = [ "d /root/.ssh 0700 root root -" "d /home/${userName}/.ssh 0700 ${userName} users -" ]; - # Generate keypair if missing (runs once) systemd.services.factory-ssh-keygen = { description = "Generate factory SSH key for ${userName} if missing"; wantedBy = [ "multi-user.target" ]; @@ -30,7 +30,6 @@ in ''; }; - # Pull the public key into root's authorized_keys once it exists systemd.services.factory-ssh-authorize = { description = "Authorize factory SSH key for root"; wantedBy = [ "multi-user.target" ]; @@ -51,4 +50,4 @@ in fi ''; }; -} \ No newline at end of file +}