nixos-config/common/services/sshd.nix
2024-04-22 13:51:35 +02:00

46 lines
929 B
Nix

{
# Hardened OpenSSH server
# Resources:
# https://cyber.gouv.fr/en/publications/openssh-secure-use-recommendations
services.openssh = {
enable = true;
# banner = "hello world";
allowSFTP = false;
settings = {
PermitRootLogin = "no";
# Public key authentiation only
PasswordAuthentication = false;
ChallengeResponseAuthentication = false;
};
extraConfig = ''
# Only allow SSH v2
Protocol 2
# Check file modes in /etc/ssh
StrictModes yes
UsePrivilegeSeparation sandbox
PrintLastLog yes
# Don't mess with environment variables
PermitUserEnvironment no
# AcceptEnv
AllowTcpForwarding no
# wip
AllowTcpForwarding yes
X11Forwarding no
AllowAgentForwarding no
AllowStreamLocalForwarding no
AuthenticationMethods publickey
'';
};
}
# ssh R6: StrictHostKeyChecking ask