home/ssh: migrate to 26.05 compat, set LOGNAME_OVERRIDE for pvv machines

This commit is contained in:
2026-06-18 17:08:16 +09:00
parent ba12a54413
commit df7b2f64bd
5 changed files with 81 additions and 77 deletions
+12 -12
View File
@@ -25,18 +25,18 @@ in
enableDefaultConfig = false;
matchBlocks."*" = {
forwardAgent = false;
addKeysToAgent = "no";
compression = false;
serverAliveInterval = 0;
serverAliveCountMax = 3;
hashKnownHosts = false;
userKnownHostsFile = "~/.ssh/known_hosts";
# controlPersist = "10m";
controlPersist = "no";
controlMaster = "auto";
controlPath = "${controlMastersDir}/%n%C";
settings."*" = {
ForwardAgent = false;
AddKeysToAgent = "no";
Compression = false;
ServerAliveInterval = 0;
ServerAliveCountMax = 3;
HashKnownHosts = false;
UserKnownHostsFile = "~/.ssh/known_hosts";
ControlPersist = "10m";
# ControlPersist = "no";
ControlMaster = "auto";
ControlPath = "${controlMastersDir}/%n%C";
};
};
+13 -13
View File
@@ -1,25 +1,25 @@
{ ... }:
{
programs.ssh.matchBlocks = {
programs.ssh.settings = {
suiseir = {
user = "h7x4";
hostname = "heimen.hopto.me";
port = 23934;
User = "h7x4";
Hostname = "heimen.hopto.me";
Port = 23934;
};
pir = {
user = "h7x4";
hostname = "gingakei.loginto.me";
port = 41348;
User = "h7x4";
Hostname = "gingakei.loginto.me";
Port = 41348;
};
tsukir = {
user = "h7x4";
hostname = "gingakei.loginto.me";
port = 45497;
User = "h7x4";
Hostname = "gingakei.loginto.me";
Port = 45497;
};
"git.nani.wtf git.tsuki.local git.seiun.cloud" = {
user = "git";
hostname = "gingakei.loginto.me";
port = 45497;
User = "git";
Hostname = "gingakei.loginto.me";
Port = 45497;
};
};
}
+6 -6
View File
@@ -1,16 +1,16 @@
{ lib, ... }:
let
default = {
user = "oysteikt";
identityFile = [ "~/.ssh/id_ed25519" ];
User = "oysteikt";
IdentityFile = [ "~/.ssh/id_ed25519" ];
};
in
{
programs.ssh.matchBlocks = {
programs.ssh.settings = {
"io" = default // {
hostname = "io.kuis.kyoto-u.ac.jp";
# SOCKS proxy for access to internal web.
dynamicForwards = [{ port = 8080; }];
# dynamicForwards = [{ port = 8080; }];
};
} // (lib.genAttrs [
"argo"
@@ -19,7 +19,7 @@ in
"vega"
"leo"
] (name: default // {
hostname = "${name}.fos.kuis.kyoto-u.ac.jp";
proxyJump = "io";
Hostname = "${name}.fos.kuis.kyoto-u.ac.jp";
ProxyJump = "io";
}));
}
+18 -18
View File
@@ -1,34 +1,34 @@
{ lib, ... }:
{
programs.ssh.matchBlocks = {
programs.ssh.settings = {
"ntnu" = {
user = "oysteikt";
hostname = "login.stud.ntnu.no";
proxyJump = "pvv";
User = "oysteikt";
Hostname = "login.stud.ntnu.no";
ProxyJump = "pvv";
};
"github" = {
user = "git";
hostname = "github.com";
identityFile = [ "~/.ssh/id_rsa" ];
User = "git";
Hostname = "github.com";
IdentityFile = [ "~/.ssh/id_rsa" ];
};
"gitlab.stud.idi.ntnu.no" = {
user = "git";
proxyJump = "pvv";
User = "git";
ProxyJump = "pvv";
};
"pascal wack" = {
user = "h7x4";
hostname = "wiki.wackattack.eu";
port = 1337;
User = "h7x4";
Hostname = "wiki.wackattack.eu";
Port = 1337;
};
"garp" = {
user = "h7x4";
hostname = "garp.pbsds.net";
proxyJump = "pvv";
User = "h7x4";
Hostname = "garp.pbsds.net";
ProxyJump = "pvv";
};
"bolle" = {
user = "h7x4";
hostname = "bolle.pbsds.net";
proxyJump = "pvv";
User = "h7x4";
Hostname = "bolle.pbsds.net";
ProxyJump = "pvv";
};
};
}
+32 -28
View File
@@ -2,14 +2,14 @@
let # http://www.pvv.ntnu.no/pvv/Maskiner
normalMachines = [
{
names = [ "hildring" "pvv-login" ];
proxyJump = lib.mkDefault null;
addressFamily = "inet";
_names = [ "hildring" "pvv-login" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
{
names = [ "drolsum" "pvv-login2" "pvv" ];
proxyJump = lib.mkDefault null;
addressFamily = "inet";
_names = [ "drolsum" "pvv-login2" "pvv" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
"bakke"
[ "bekkalokk" "pvv-web" "pvv-wiki" "pvv-webmail" ]
@@ -31,9 +31,9 @@ let # http://www.pvv.ntnu.no/pvv/Maskiner
"lupine-4"
"lupine-5"
{
names = [ "microbel" "pvv-users" "pvv-mail" ];
proxyJump = lib.mkDefault null;
addressFamily = "inet";
_names = [ "microbel" "pvv-users" "pvv-mail" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
"mirage"
"orchid"
@@ -57,8 +57,8 @@ let # http://www.pvv.ntnu.no/pvv/Maskiner
[ "principal" "pvv-backup" ]
[ "skrott" "dibbler" ]
{
names = [ "sleipner" "pvv-salt" ];
user = "oysteikt/admin";
_names = [ "sleipner" "pvv-salt" ];
User = "oysteikt/admin";
}
"buskerud"
"smask"
@@ -69,37 +69,41 @@ let # http://www.pvv.ntnu.no/pvv/Maskiner
overrideIfNotExists = b: a: a // (builtins.removeAttrs b (builtins.attrNames a));
coerce = user: machines: lib.pipe machines [
(m: if builtins.isString m then { names = [m]; } else m)
(m: if builtins.isList m then { names = m; } else m)
(overrideIfNotExists { inherit user; })
coerce = User: machines: lib.pipe machines [
(m: if builtins.isString m then { _names = [m]; } else m)
(m: if builtins.isList m then { _names = m; } else m)
(overrideIfNotExists { inherit User; })
];
normalUser = "oysteikt";
matchConfig = let
machines = (map (coerce normalUser) normalMachines) ++ (map (coerce "root") rootMachines);
setVars = orig@{ names, ... }: {
name = builtins.concatStringsSep " " names;
machines = (map (coerce normalUser) normalMachines) ++ (map (m: (coerce "root" m) // {
SetEnv = {
LOGNAME_OVERRIDE = "%u";
};
}) rootMachines);
setVars = orig@{ _names, ... }: {
name = builtins.concatStringsSep " " _names;
value = overrideIfNotExists {
hostname = "${builtins.head names}.pvv.ntnu.no";
proxyJump = "microbel";
addressFamily = "inet";
} (builtins.removeAttrs orig ["names"]);
Hostname = "${builtins.head _names}.pvv.ntnu.no";
ProxyJump = "microbel";
AddressFamily = "inet";
} (builtins.removeAttrs orig ["_names"]);
};
in builtins.listToAttrs (map setVars machines);
in
{
programs.ssh.matchBlocks = lib.mergeAttrsList [
programs.ssh.settings = lib.mergeAttrsList [
matchConfig
{
"pvv-git git.pvv.ntnu.no" = {
hostname = "git.pvv.ntnu.no";
user = "gitea";
addressFamily = "inet";
port = 2222;
proxyJump = "microbel";
Hostname = "git.pvv.ntnu.no";
User = "gitea";
AddressFamily = "inet";
Port = 2222;
ProxyJump = "microbel";
};
}
];