From 5018fbbee5bbbc684dd4bbda1fc59b5b3b96e64c Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Fri, 5 May 2023 13:29:39 +0100 Subject: [PATCH] Restructure SSH config similar to Git for personal/work separation --- home/Monarch-tux.nix | 2 +- home/collections/common/desktop.nix | 1 - home/collections/personal/default.nix | 14 +------------ home/collections/work/default.nix | 28 ++----------------------- home/{env/ssh.nix => ssh/common.nix} | 3 +-- home/ssh/personal.nix | 17 +++++++++++++++ home/ssh/work.nix | 30 +++++++++++++++++++++++++++ ssh/config.d/git.conf | 2 -- ssh/config.d/ukaea.conf | 14 ------------- ssh/config.d/xenia.conf | 7 ------- 10 files changed, 52 insertions(+), 66 deletions(-) rename home/{env/ssh.nix => ssh/common.nix} (80%) create mode 100644 home/ssh/personal.nix create mode 100644 home/ssh/work.nix delete mode 100644 ssh/config.d/git.conf delete mode 100644 ssh/config.d/ukaea.conf delete mode 100644 ssh/config.d/xenia.conf diff --git a/home/Monarch-tux.nix b/home/Monarch-tux.nix index 1fe6db53..b0894433 100644 --- a/home/Monarch-tux.nix +++ b/home/Monarch-tux.nix @@ -6,8 +6,8 @@ ./env/bat.nix ./env/direnv.nix ./env/keychain.nix - ./env/ssh.nix ./env/starship.nix + ./ssh/personal.nix ./terminal/wezterm.nix ./tui/neovim.nix ./tui/lazygit.nix diff --git a/home/collections/common/desktop.nix b/home/collections/common/desktop.nix index 7961abb1..017b1b88 100644 --- a/home/collections/common/desktop.nix +++ b/home/collections/common/desktop.nix @@ -9,7 +9,6 @@ ../../env/direnv.nix ../../env/keychain.nix ../../env/pypoetry.nix - ../../env/ssh.nix ../../env/starship.nix ../../terminal/wezterm.nix ../../tui/neovim.nix diff --git a/home/collections/personal/default.nix b/home/collections/personal/default.nix index d7811cf1..7c6a6fc7 100644 --- a/home/collections/personal/default.nix +++ b/home/collections/personal/default.nix @@ -3,20 +3,8 @@ imports = [ ../common/desktop.nix ../../git/personal.nix + ../../ssh/personal.nix ]; - programs.ssh.matchBlocks = { - "legion xenia xenia.me.uk" = { - user = "xenia"; - hostname = "xenia.me.uk"; - port = 30; - forwardAgent = true; - }; - "vanguard" = { - user = "xenia"; - hostname = "192.168.1.166"; - forwardAgent = true; - }; - }; home.packages = with pkgs; [ discord element-desktop diff --git a/home/collections/work/default.nix b/home/collections/work/default.nix index ff64a9fc..3acd84b1 100644 --- a/home/collections/work/default.nix +++ b/home/collections/work/default.nix @@ -1,34 +1,10 @@ -{ pkgs, lib, ... }: +{ pkgs, ... }: { imports = [ ../common/desktop.nix ../../git/work.nix + ../../ssh/work.nix ]; - programs.ssh.matchBlocks = { - "batch" = { - user = "cxsbatch"; - hostname = "heimdall115.jetdata.eu"; - }; - "jupyter" = { - hostname = "freia022.hpc.l"; - localForwards = [ - { - bind.port = 6702; - host.address = "localhost"; - host.port = 6702; - } - ]; - }; - "freia" = { - hostname = "freia022.hpc.l"; - }; - "freia???" = lib.hm.dag.entryAfter [ "freia" ] { - hostname = "%h.hpc.l"; - }; - "freia* jupyter" = lib.hm.dag.entryAfter [ "freia" "freia???" "jupyter" ] { - user = "elitherl"; - }; - }; home.packages = with pkgs; [ libreoffice-fresh neovide diff --git a/home/env/ssh.nix b/home/ssh/common.nix similarity index 80% rename from home/env/ssh.nix rename to home/ssh/common.nix index ecce075d..577cef78 100644 --- a/home/env/ssh.nix +++ b/home/ssh/common.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ ... }: { programs.ssh = { enable = true; @@ -9,5 +9,4 @@ controlPersist = "1s"; matchBlocks."git.*".user = "git"; }; - home.packages = with pkgs; [ sshfs ]; } diff --git a/home/ssh/personal.nix b/home/ssh/personal.nix new file mode 100644 index 00000000..bbf57093 --- /dev/null +++ b/home/ssh/personal.nix @@ -0,0 +1,17 @@ +{ ... }: +{ + imports = [ ./common.nix ]; + programs.ssh.matchBlocks = { + "legion xenia xenia.me.uk" = { + user = "xenia"; + hostname = "xenia.me.uk"; + port = 30; + forwardAgent = true; + }; + "vanguard" = { + user = "xenia"; + hostname = "192.168.1.166"; + forwardAgent = true; + }; + }; +} diff --git a/home/ssh/work.nix b/home/ssh/work.nix new file mode 100644 index 00000000..1ae13f3d --- /dev/null +++ b/home/ssh/work.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, ... }: +{ + imports = [ ./common.nix ]; + home.packages = with pkgs; [ sshfs ]; + programs.ssh.matchBlocks = { + "batch" = { + user = "cxsbatch"; + hostname = "heimdall115.jetdata.eu"; + }; + "jupyter" = { + hostname = "freia022.hpc.l"; + localForwards = [ + { + bind.port = 6702; + host.address = "localhost"; + host.port = 6702; + } + ]; + }; + "freia" = { + hostname = "freia022.hpc.l"; + }; + "freia???" = lib.hm.dag.entryAfter [ "freia" ] { + hostname = "%h.hpc.l"; + }; + "freia* jupyter" = lib.hm.dag.entryAfter [ "freia" "freia???" "jupyter" ] { + user = "elitherl"; + }; + }; +} diff --git a/ssh/config.d/git.conf b/ssh/config.d/git.conf deleted file mode 100644 index 4a9c7d3e..00000000 --- a/ssh/config.d/git.conf +++ /dev/null @@ -1,2 +0,0 @@ -Host git.ccfe.ac.uk - user git diff --git a/ssh/config.d/ukaea.conf b/ssh/config.d/ukaea.conf deleted file mode 100644 index 97ccb0df..00000000 --- a/ssh/config.d/ukaea.conf +++ /dev/null @@ -1,14 +0,0 @@ -# vim: ft=sshconfig -Host batch - User cxsbatch - HostName heimdall115.jetdata.eu - -Host freia - HostName freia022.hpc.l - LocalForward 6702 localhost:6702 - -Host freia??? - HostName %h.hpc.l - -Host freia* - User elitherl diff --git a/ssh/config.d/xenia.conf b/ssh/config.d/xenia.conf deleted file mode 100644 index 1ea1ec75..00000000 --- a/ssh/config.d/xenia.conf +++ /dev/null @@ -1,7 +0,0 @@ -# vim: ft=sshconfig - -Host legion xenia xenia.me.uk - User xenia - HostName xenia.me.uk - Port 30 - ForwardAgent yes