Summary Files Commits Branches @commit @diff @stats
path: root / modules / server / ftp.nix
blob: 31a7cf9e73836f1959b702bd528ddaa2a8efdf5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  networking.firewall.allowedTCPPorts = [ 20 21 ] ++ /* passive mode ports */ builtins.genList (x: x + 2100) 10;
  services.vsftpd = {
    enable = true;
    writeEnable = true;
    allowWriteableChroot = true;
    chrootlocalUser = true;

    userlist = [ "anonymous" ];
    anonymousUser = true;
    anonymousUserNoPassword = true;
    anonymousUploadEnable = true;
    anonymousMkdirEnable = true;
    # Do note, anonymous users cannot write in their home (chroot) directory, period.
    # The home dir must have non-write permissions and instead there should be a write-able subdirectory inside.
    anonymousUserHome = "/home/ftp";
    anonymousUmask = "0";

    extraConfig = ''
      # Enable passive mode, it seems most GUI tools use it
      # Thanks https://serverfault.com/a/421169
      pasv_enable=YES
      pasv_min_port=2100
      pasv_max_port=2109

      # More anonymous user permissions
      anon_world_readable_only=NO
      anon_other_write_enable=YES

      # Other
      ftpd_banner=Мрежова папка
    '';
  };
}