This commit is contained in:
2025-03-10 12:30:10 +01:00
parent 0358c68402
commit a88805813b
2 changed files with 52 additions and 0 deletions

View File

@@ -34,6 +34,8 @@
../../../users/h7x4
../../../users/adrlau
./sftp.nix
../../../profiles/shell.nix
../../../profiles/domeneshop-dyndns.nix

50
hosts/nixos/garp/sftp.nix Normal file
View File

@@ -0,0 +1,50 @@
{ lib, config, ...}:
let
sftp-paths."ifield" = "/opt/ifield";
# user = config.users.users."sftp";
user.home = "/home/sftp"; # ininite recursion...
in
{
users.users."sftp" = {
isNormalUser = true;
createHome = true;
uid = 3000;
inherit (user) home;
# TODO: can I somehow idmap instead?
extraGroups = [ "users" "pbsds" ];
#hashedPassword = ""; # use mkpasswd
openssh.authorizedKeys.keys = lib.mkMerge [
[
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKaE4W5Qe+ZBRtsY2KiIHbpx6v+8KrgrVT8ZgFvSVbvz ifield-sftp"
]
# no work?
# config.users.users."pbsds".authorizedKeys.keys
];
};
services.openssh.sftpServerExecutable = "internal-sftp";
services.openssh.extraConfig = ''
Match User sftp
ChrootDirectory ${user.home}
ForceCommand internal-sftp
PasswordAuthentication no
PubkeyAuthentication yes
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
'';
imports = lib.flip lib.mapAttrsToList sftp-paths (target: source: {
fileSystems."${user.home}/${target}" = {
device = source;
options = ["ro" "bind"]; # Read only
# depends = [ "/" ];
noCheck = true; # skip fsck
};
});
}