From 96e4afa3eb22305cd377aa1df4dcb4cc140acb0d Mon Sep 17 00:00:00 2001 From: osbm Date: Wed, 19 Feb 2025 10:52:16 +0300 Subject: [PATCH] add ssh --- hosts/atreus/configuration.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hosts/atreus/configuration.nix b/hosts/atreus/configuration.nix index 6293d20..83e2e5c 100644 --- a/hosts/atreus/configuration.nix +++ b/hosts/atreus/configuration.nix @@ -9,9 +9,10 @@ vim # or some other editor, e.g. nano or neovim # Some common stuff that people expect to have - #procps + procps #killall #diffutils + inetutils findutils utillinux tzdata @@ -34,6 +35,10 @@ openssh just nh + (pkgs.writeShellScriptBin "sshd-start" '' + echo "Starting sshd on port 8022" + ${pkgs.openssh}/bin/sshd + '') ]; # Backup etc files instead of failing to activate generation if a file already exists in /etc @@ -49,4 +54,21 @@ # Set your time zone #time.timeZone = "Europe/Berlin"; + + build.activation.sshd = '' + if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then + $VERBOSE_ECHO "Generating host keys..." + $DRY_RUN_CMD ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -a 32 -f "/etc/ssh/ssh_host_ed25519_key" -N "" + fi + ''; + + environment.etc."ssh/sshd_config".text = '' + AcceptEnv LANG LC_* + KbdInteractiveAuthentication no + PasswordAuthentication no + PermitRootLogin no + Port 8022 + PrintMotd no + ''; + }