From 99d0e6cf5063b3a978dd08240db500f887b8387f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 9 Sep 2024 12:43:29 +0200 Subject: [PATCH] Make ssh to bmo not use proxy when on eduroam --- home/ssh/config.nix | 35 +++++++++++++++++++++++++++++++++++ home/ssh/default.nix | 2 +- home/ssh/gunter.nix | 16 ---------------- 3 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 home/ssh/config.nix delete mode 100644 home/ssh/gunter.nix diff --git a/home/ssh/config.nix b/home/ssh/config.nix new file mode 100644 index 0000000..17a2375 --- /dev/null +++ b/home/ssh/config.nix @@ -0,0 +1,35 @@ +{ pkgs, lib, ... }: +let + eduroam-active = pkgs.writeShellApplication { + name = "eduroam-active"; + runtimeInputs = with pkgs; [ + networkmanager + ]; + text = '' + nmcli -g GENERAL.STATE c s interface|grep -q -E '\bactiv' + ''; + }; +in +{ + programs.ssh = { + enable = true; + controlMaster = "auto"; + + matchBlocks = { + "bmo.uio.no-on-eduroam" = lib.hm.dag.entryBefore [ "bmo.uio.no" ] { + match = "host bmo.uio.no exec \"nmcli -g GENERAL.STATE c s eduroam|grep -q -E '\\bactiv'\""; + hostname = "bmo.uio.no"; + forwardAgent = false; + }; + + "bmo.uio.no" = { + setEnv = { + # TERM = "xterm-256color"; + }; + hostname = "bmo.uio.no"; + forwardAgent = false; + proxyJump = "torjus@rlogin.uio.no"; + }; + }; + }; +} diff --git a/home/ssh/default.nix b/home/ssh/default.nix index da32aec..d7fe506 100644 --- a/home/ssh/default.nix +++ b/home/ssh/default.nix @@ -1 +1 @@ -{ imports = [ ./gunter.nix ]; } +{ imports = [ ./config.nix ]; } diff --git a/home/ssh/gunter.nix b/home/ssh/gunter.nix deleted file mode 100644 index 71736d1..0000000 --- a/home/ssh/gunter.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, ... }: -{ - programs.ssh = { - enable = true; - controlMaster = "auto"; - - matchBlocks."bmo.uio.no" = { - setEnv = { - # TERM = "xterm-256color"; - }; - hostname = "bmo.uio.no"; - forwardAgent = false; - proxyJump = "torjus@rlogin.uio.no"; - }; - }; -}