1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
{ customUtils, lib, config, hostName, pkgs, ... }:
{
config = {
systemd.user.services."ssh-agent".enable = lib.mkForce false; # ssh-agent should be done via home-manager
services.openssh = lib.mkIf config.services.openssh.enable {
hostKeys = lib.mkForce []; # done manually
ciphers = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" "aes256-ctr" ];
macs = [ "hmac-sha2-256-etm@openssh.com" "hmac-sha2-256" "hmac-sha2-512-etm@openssh.com" "hmac-sha2-512" ];
kexAlgorithms = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ];
moduliFile = config.sops.secrets.ssh_moduli.path;
extraConfig = ''
HostKeyAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-256,rsa-sha2-512
CASignatureAlgorithms sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-256,rsa-sha2-512
HostKey /etc/ssh/ssh_host_ed25519_key
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
HostKey /etc/ssh/ssh_host_rsa_key
HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
RevokedKeys /etc/ssh/krl.bin
'';
logLevel = "VERBOSE";
};
programs.ssh = {
knownHosts = {
"*.yggdrasil.li" = {
extraHostNames = ["*.yggdrasil"];
certAuthority = true;
publicKeyFile = ./ca/ca.pub;
};
};
knownHostsFiles = [
./known-hosts/borgbase.keys
];
ciphers = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" "aes256-ctr" ];
hostKeyAlgorithms = [ "sk-ssh-ed25519-cert-v01@openssh.com" "ssh-ed25519-cert-v01@openssh.com" "rsa-sha2-256-cert-v01@openssh.com" "rsa-sha2-512-cert-v01@openssh.com" "sk-ssh-ed25519@openssh.com" "ssh-ed25519" "rsa-sha2-256" "rsa-sha2-512" ];
kexAlgorithms = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ];
macs = [ "umac-128-etm@openssh.com" "hmac-sha2-256-etm@openssh.com" "hmac-sha2-512-etm@openssh.com" "umac-128@openssh.com" "hmac-sha2-256" "hmac-sha2-512" "umac-64-etm@openssh.com" "umac-64@openssh.com"];
pubkeyAcceptedKeyTypes = [ "ssh-ed25519" "ssh-rsa" ];
extraConfig = ''
Host *
CASignatureAlgorithms sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-256,rsa-sha2-512
'';
};
sops.secrets = lib.mkIf config.services.openssh.enable {
ssh_host_rsa_key = {
key = "rsa";
path = "/etc/ssh/ssh_host_rsa_key";
sopsFile = ./host-keys + "/${hostName}.yaml";
};
ssh_host_ed25519_key = {
key = "ed25519";
path = "/etc/ssh/ssh_host_ed25519_key";
sopsFile = ./host-keys + "/${hostName}.yaml";
};
ssh_moduli = {
format = "binary";
path = "/etc/ssh/moduli";
sopsFile = ./host-moduli + "/${hostName}";
};
};
environment.etc = lib.mkIf config.services.openssh.enable {
"ssh/ssh_host_rsa_key.pub".source = ./known-hosts + "/${hostName}/rsa.pub";
"ssh/ssh_host_ed25519_key.pub".source = ./known-hosts + "/${hostName}/ed25519.pub";
"ssh/ssh_host_rsa_key-cert.pub".source = ./known-hosts + "/${hostName}/rsa-cert.pub";
"ssh/ssh_host_ed25519_key-cert.pub".source = ./known-hosts + "/${hostName}/ed25519-cert.pub";
"ssh/krl.bin".source = ./ca/krl.bin;
};
environment.systemPackages = lib.mkIf config.services.openssh.enable (with pkgs; [
rxvt_unicode.terminfo alacritty.terminfo
]);
};
}
|