key to unlock boot correct
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@@ -17,8 +18,8 @@ in
|
||||
};
|
||||
|
||||
hostKeyPath = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = /etc/secrets/initrd/ssh_host_ed25519_key;
|
||||
type = lib.types.str;
|
||||
default = "/persist/etc/secrets/initrd/ssh_host_ed25519_key";
|
||||
description = "Path to the initrd SSH host private key on the target system.";
|
||||
};
|
||||
|
||||
@@ -31,22 +32,24 @@ in
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.kernelParams = [ "ip=dhcp" ];
|
||||
|
||||
boot.initrd.network = {
|
||||
enable = true;
|
||||
ssh = {
|
||||
enable = true;
|
||||
port = cfg.port;
|
||||
hostKeys = [ (toString cfg.hostKeyPath) ];
|
||||
hostKeys = [ cfg.hostKeyPath ];
|
||||
authorizedKeys = cfg.authorizedKeys;
|
||||
};
|
||||
};
|
||||
|
||||
system.activationScripts.initrdSshHostKey = {
|
||||
deps = [ "users" "groups" ];
|
||||
text = ''
|
||||
install -d -m 700 "$(dirname ${toString cfg.hostKeyPath})"
|
||||
if [ ! -f "${toString cfg.hostKeyPath}" ]; then
|
||||
ssh-keygen -t ed25519 -N "" -f "${toString cfg.hostKeyPath}"
|
||||
chmod 600 "${toString cfg.hostKeyPath}"
|
||||
install -d -m 700 "$(dirname "${cfg.hostKeyPath}")"
|
||||
if [ ! -f "${cfg.hostKeyPath}" ]; then
|
||||
${pkgs.openssh}/bin/ssh-keygen -t ed25519 -N "" -f "${cfg.hostKeyPath}"
|
||||
chmod 600 "${cfg.hostKeyPath}"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user