Skip to content

Commit 92f7499

Browse files
Merge pull request #322 from NuschtOS/ssh
2 parents 9e9c2e2 + 46426ba commit 92f7499

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

modules/gitea.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ in
210210
# see https://github.com/go-gitea/gitea/issues/31112
211211
OFFLINE_MODE = false;
212212
ROOT_URL = "https://${cfg.settings.server.DOMAIN}/";
213-
SSH_SERVER_CIPHERS = "[email protected], [email protected], aes128-gcm@openssh.com";
214-
SSH_SERVER_KEY_EXCHANGES = "[email protected], ecdh-sha2-nistp521, ecdh-sha2-nistp384, ecdh-sha2-nistp256, diffie-hellman-group14-sha1";
215-
SSH_SERVER_MACS = "[email protected], hmac-sha2-256, hmac-sha1";
213+
SSH_SERVER_CIPHERS = lib.concatStringsSep ", " config.services.openssh.settings.Ciphers;
214+
SSH_SERVER_KEY_EXCHANGES = lib.concatStringsSep ", " config.services.openssh.settings.KexAlgorithms;
215+
SSH_SERVER_MACS = lib.concatStringsSep ", " config.services.openssh.settings.Macs;
216216
};
217217
session = {
218218
COOKIE_SECURE = true;

modules/ssh.nix

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ in
1212
addPopularKnownHosts = libS.mkOpinionatedOption "add ssh public keys of popular websites to known_hosts";
1313
addHelpOnHostkeyMismatch = libS.mkOpinionatedOption "show a ssh-keygen command to remove mismatching ssh knownhosts entries";
1414
recommendedDefaults = libS.mkOpinionatedOption "set recommend and secure default settings";
15+
16+
package = lib.mkOption {
17+
apply = p: if cfgP.addHelpOnHostkeyMismatch then
18+
(p.overrideAttrs ({ patches, ... }: {
19+
patches = patches ++ [
20+
(pkgs.fetchpatch {
21+
urls =
22+
let
23+
version = "1%259.9p1-1";
24+
in
25+
[
26+
"https://salsa.debian.org/ssh-team/openssh/-/raw/debian/${version}/debian/patches/mention-ssh-keygen-on-keychange.patch"
27+
];
28+
hash = "sha256-OZPOHwQkclUAjG3ShfYX66sbW2ahXPgsV6XNfzl9SIg=";
29+
})
30+
];
31+
32+
# takes to long and unstable requires openssh to work to advance
33+
doCheck = false;
34+
}))
35+
else
36+
p;
37+
};
1538
};
1639

1740
services.openssh = {
@@ -63,36 +86,17 @@ in
6386
(libS.mkPubKey "*.your-storagebox.de" "ssh-rsa" "AAAAB3NzaC1yc2EAAAABIwAAAQEA5EB5p/5Hp3hGW1oHok+PIOH9Pbn7cnUiGmUEBrCVjnAw+HrKyN8bYVV0dIGllswYXwkG/+bgiBlE6IVIBAq+JwVWu1Sss3KarHY3OvFJUXZoZyRRg/Gc/+LRCE7lyKpwWQ70dbelGRyyJFH36eNv6ySXoUYtGkwlU5IVaHPApOxe4LHPZa/qhSRbPo2hwoh0orCtgejRebNtW5nlx00DNFgsvn8Svz2cIYLxsPVzKgUxs8Zxsxgn+Q/UvR7uq4AbAhyBMLxv7DjJ1pc7PJocuTno2Rw9uMZi1gkjbnmiOh6TTXIEWbnroyIhwc8555uto9melEUmWNQ+C+PwAK+MPw==")
6487
(libS.mkPubKey "*.your-storagebox.de" "ssh-ed25519" "AAAAC3NzaC1lZDI1NTE5AAAAIICf9svRenC/PLKIL9nk6K/pxQgoiFC41wTNvoIncOxs")
6588
]);
66-
package = lib.mkIf cfgP.addHelpOnHostkeyMismatch (pkgs.openssh.overrideAttrs ({ patches, ... }: {
67-
patches = patches ++ [
68-
(pkgs.fetchpatch {
69-
urls =
70-
let
71-
version = "1%259.9p1-1";
72-
in
73-
[
74-
"https://salsa.debian.org/ssh-team/openssh/-/raw/debian/${version}/debian/patches/mention-ssh-keygen-on-keychange.patch"
75-
];
76-
hash = "sha256-OZPOHwQkclUAjG3ShfYX66sbW2ahXPgsV6XNfzl9SIg=";
77-
})
78-
];
79-
80-
# takes to long and unstable requires openssh to work to advance
81-
doCheck = false;
82-
}));
8389
};
8490

8591
services.openssh = lib.mkIf cfgS.recommendedDefaults {
8692
settings = {
87-
# following ssh-audit: nixos default minus 2048 bit modules (diffie-hellman-group-exchange-sha256)
93+
# following ssh-audit: nixos default minus 2048 bit modules (diffie-hellman-group-exchange-sha256) and not post-quantum safe (curve25519-sha256)
8894
KexAlgorithms = [
8995
"mlkem768x25519-sha256"
9096
"sntrup761x25519-sha512"
9197
92-
"curve25519-sha256"
93-
9498
];
95-
# following ssh-audit: nixos defaults minus encrypt-and-MAC
99+
# following ssh-audit: nixos defaults
96100
Macs = [
97101
98102

0 commit comments

Comments
 (0)