add sshd for aws generators

This commit is contained in:
Noah Masur 2022-09-20 11:50:45 +00:00
parent 50a538c78e
commit 9e3345ff9b
2 changed files with 27 additions and 0 deletions

View File

@ -11,9 +11,12 @@ nixos-generators.nixoGenerate {
colorscheme = (import ../../modules/colorscheme/gruvbox); colorscheme = (import ../../modules/colorscheme/gruvbox);
passwordHash = passwordHash =
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
} }
../hosts/common.nix ../hosts/common.nix
../modules/nixos ../modules/nixos
../modules/services/sshd.nix
]; ];
format = "aws"; format = "aws";
} }

24
modules/services/sshd.nix Normal file
View File

@ -0,0 +1,24 @@
{ config, pkgs, lib, ... }: {
options = {
publicKey = lib.mkOption {
type = lib.types.str;
description = "Public SSH key authorized for this system.";
};
};
config = {
services.openssh = {
enable = true;
ports = [ 22 ];
passwordAuthentication = false;
gatewayPorts = "no";
forwardX11 = false;
allowSFTP = true;
permitRootLogin = "no";
};
users.users.${config.user}.authorizedKeys.keys = [ config.publicKey ];
};
}