From fd3e0966cfc067044f4b03c9c688b010394512bf Mon Sep 17 00:00:00 2001 From: Benedikt Ritter Date: Thu, 21 Nov 2024 13:56:11 +0100 Subject: [PATCH] home (terminal): Configure ssh for easier access to my homelab --- home/terminal/default.nix | 2 ++ home/terminal/ssh.nix | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 home/terminal/ssh.nix diff --git a/home/terminal/default.nix b/home/terminal/default.nix index 6052988..7be2f35 100644 --- a/home/terminal/default.nix +++ b/home/terminal/default.nix @@ -16,6 +16,7 @@ in { ./gpg ./helix.nix ./nvim + ./ssh.nix ./tmux.nix ./tools.nix ./yazi.nix @@ -35,6 +36,7 @@ in { gpg.enable = true; helix.enable = true; nvim.enable = true; + ssh.enable = true; tmux.enable = true; tools.enable = true; yazi.enable = true; diff --git a/home/terminal/ssh.nix b/home/terminal/ssh.nix new file mode 100644 index 0000000..ba4f5f7 --- /dev/null +++ b/home/terminal/ssh.nix @@ -0,0 +1,57 @@ +{ + config, + lib, + osConfig, + ... +}: let + cfg = config.my.home.terminal.ssh; +in { + options.my.home.terminal.ssh = { + enable = lib.mkEnableOption "ssh"; + }; + config = lib.mkIf cfg.enable { + programs.ssh = { + enable = true; + matchBlocks = let + sshDirectory = "${config.home.homeDirectory}/.ssh"; + privateKey = "${sshDirectory}/id_ed25519"; + in { + "github.com" = { + hostname = "github.com"; + identityFile = privateKey; + identitiesOnly = true; + }; + directions = { + hostname = osConfig.my.homelab.directions.ip; + identityFile = privateKey; + user = "root"; + }; + "srv-prod-1" = { + hostname = osConfig.my.homelab.srv-prod-1.ip; + identityFile = privateKey; + user = "root"; + }; + "srv-prod-2" = { + hostname = osConfig.my.homelab.srv-prod-2.ip; + identityFile = privateKey; + user = "root"; + }; + "srv-test-1" = { + hostname = osConfig.my.homelab.srv-test-1.ip; + identityFile = privateKey; + user = "root"; + }; + "srv-test-2" = { + hostname = osConfig.my.homelab.srv-test-2.ip; + identityFile = privateKey; + user = "root"; + }; + "srv-eval-1" = { + hostname = osConfig.my.homelab.srv-eval-1.ip; + identityFile = privateKey; + user = "root"; + }; + }; + }; + }; +}