updated ssh-bootstrap
This commit is contained in:
@@ -3,15 +3,15 @@
|
|||||||
let
|
let
|
||||||
userName = "free";
|
userName = "free";
|
||||||
keyPath = "/home/${userName}/.ssh/factory_login";
|
keyPath = "/home/${userName}/.ssh/factory_login";
|
||||||
|
userExists = builtins.hasAttr userName config.users.users;
|
||||||
in
|
in
|
||||||
{
|
lib.mkIf userExists {
|
||||||
# Ensure SSH dirs exist with correct perms
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /root/.ssh 0700 root root -"
|
"d /root/.ssh 0700 root root -"
|
||||||
"d /home/${userName}/.ssh 0700 ${userName} users -"
|
"d /home/${userName}/.ssh 0700 ${userName} users -"
|
||||||
];
|
];
|
||||||
|
|
||||||
# Generate keypair if missing (runs once)
|
|
||||||
systemd.services.factory-ssh-keygen = {
|
systemd.services.factory-ssh-keygen = {
|
||||||
description = "Generate factory SSH key for ${userName} if missing";
|
description = "Generate factory SSH key for ${userName} if missing";
|
||||||
wantedBy = [ "multi-user.target" ];
|
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 = {
|
systemd.services.factory-ssh-authorize = {
|
||||||
description = "Authorize factory SSH key for root";
|
description = "Authorize factory SSH key for root";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|||||||
Reference in New Issue
Block a user