mirror of
https://github.com/lxstinthesky/matrix.git
synced 2025-11-07 19:32:44 +00:00
Compare commits
5 Commits
981683bf51
...
nixos-base
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c31f778ac2 | ||
|
|
f224a79f30 | ||
|
|
27f18dc6ec | ||
|
|
63f40f5937 | ||
|
|
c8996554fb |
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
# nix settings
|
# nix settings
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
nix.settings.download-buffer-size = 524288000; # 500MB
|
||||||
|
|
||||||
# Bootloader to work with LUKS
|
# Bootloader to work with LUKS
|
||||||
boot.loader.grub = {
|
boot.loader.grub = {
|
||||||
@@ -73,6 +74,11 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# this is related to luks remote unlock via ssh
|
||||||
|
# Disable initrd secrets for VM builds to avoid secret error
|
||||||
|
# Error is not present in real depolyments
|
||||||
|
boot.initrd.secrets = lib.mkForce {};
|
||||||
|
|
||||||
# Add VM-specific users
|
# Add VM-specific users
|
||||||
users.users.smith = {
|
users.users.smith = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
|
|||||||
@@ -8,8 +8,66 @@
|
|||||||
PermitRootLogin = "no"; # Disable root login
|
PermitRootLogin = "no"; # Disable root login
|
||||||
PasswordAuthentication = false; # Force SSH key auth only
|
PasswordAuthentication = false; # Force SSH key auth only
|
||||||
PubkeyAuthentication = true; # Enable SSH keys
|
PubkeyAuthentication = true; # Enable SSH keys
|
||||||
|
LogLevel = "VERBOSE"; # More detailed logging, for fail2ban
|
||||||
};
|
};
|
||||||
ports = [ 22 ];
|
ports = [ 22 ];
|
||||||
|
# using the same key as for initrd
|
||||||
|
hostKeys = [
|
||||||
|
{ path = "/etc/secrets/initrd/ssh_host_ed25519_key"; type = "ed25519"; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.fail2ban = {
|
||||||
|
enable = true;
|
||||||
|
maxretry = 5; # Ban IP after 5 failures
|
||||||
|
ignoreIP = [
|
||||||
|
|
||||||
|
];
|
||||||
|
bantime = "24h"; # Ban IPs for one day on the first ban
|
||||||
|
bantime-increment = {
|
||||||
|
enable = true; # Enable increment of bantime after each violation
|
||||||
|
multipliers = "1 2 3 4 5 6 7"; # everytime one day more
|
||||||
|
maxtime = "168h"; # Do not ban for more than 1 week
|
||||||
|
overalljails = true; # Calculate the bantime based on all the violations
|
||||||
|
};
|
||||||
|
|
||||||
|
# fail2ban ships with a default sshd jail, we override it here, to be explicit
|
||||||
|
jails.sshd.settings = {
|
||||||
|
port = 22; # explicit
|
||||||
|
maxretry = 5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# remote unlock for luks via ssh
|
||||||
|
boot.kernelParams = [ "ip=dhcp" ];
|
||||||
|
boot.initrd = {
|
||||||
|
availableKernelModules = [ "virtio-pci" ];
|
||||||
|
network = {
|
||||||
|
enable = true;
|
||||||
|
ssh = {
|
||||||
|
enable = true;
|
||||||
|
port = 22;
|
||||||
|
authorizedKeys = [
|
||||||
|
(builtins.readFile ../users/keys/neo.pub)
|
||||||
|
(builtins.readFile ../users/keys/morpheus.pub)
|
||||||
|
];
|
||||||
|
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
|
||||||
|
shell = "/bin/cryptsetup-askpass";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Generate SSH host key for initrd
|
||||||
|
system.activationScripts.initrd-ssh-key = {
|
||||||
|
text = ''
|
||||||
|
mkdir -p /etc/secrets/initrd
|
||||||
|
if [ ! -f /etc/secrets/initrd/ssh_host_ed25519_key ]; then
|
||||||
|
${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f /etc/secrets/initrd/ssh_host_ed25519_key -N ""
|
||||||
|
chmod 600 /etc/secrets/initrd/ssh_host_ed25519_key
|
||||||
|
chmod 644 /etc/secrets/initrd/ssh_host_ed25519_key.pub
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
deps = [ ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# other security hardening options can go here
|
# other security hardening options can go here
|
||||||
|
|||||||
1
nix/users/keys/morpheus.pub
Normal file
1
nix/users/keys/morpheus.pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGYkZY9rUTaN7LrmA5MVU+I+at1YV+i2e3EkGfCIt4M2 robin@thor
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
|
|
||||||
users.users.morpheus = {
|
users.users.morpheus = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = "Insert joke here";
|
description = "I'm colorblind";
|
||||||
extraGroups = [ "networkmanager" "wheel" ];
|
extraGroups = [ "networkmanager" "wheel" ];
|
||||||
shell = pkgs.zsh;
|
shell = pkgs.zsh;
|
||||||
packages = with pkgs; [ ];
|
packages = with pkgs; [ ];
|
||||||
|
openssh.authorizedKeys.keyFiles = [
|
||||||
|
./keys/morpheus.pub
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.trinity = {
|
users.users.trinity = {
|
||||||
|
|||||||
Reference in New Issue
Block a user