LAN内に匿名OKなFTPサーバを建てる


(クローズドな環境で)誰でもファイルダウンロードできる FTP サーバを建てたかったので設定。

  • 環境
    
    $ uname -a
    Linux rpi4 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux

$ cat /etc/issue
Debian GNU/Linux 12 \n \l


- インストール
```shell
$ sudo apt update -y && sudo apt upgrade -y
$ sudo apt install -y vsftpd
  • 設定
    匿名ユーザ受け入れ設定。(あくまでダウンロード専用)

    $ diff -u /tmp/vsftpd.conf /etc/vsftpd.conf 
    --- /tmp/vsftpd.conf    2025-01-17 20:24:22.319336631 +0900
    +++ /etc/vsftpd.conf    2025-01-17 20:26:16.675828663 +0900
    @@ -11,7 +11,7 @@
    #
    # Run standalone?  vsftpd can run either from an inetd or as a standalone
    # daemon started from an initscript.
    -listen=NO
    +listen=YES
    #
    # This directive enables listening on IPv6 sockets. By default, listening
    # on the IPv6 "any" address (::) will accept connections from both IPv6
    @@ -19,16 +19,16 @@
    # sockets. If you want that (perhaps because you want to listen on specific
    # addresses) then you must run two copies of vsftpd with two configuration
    # files.
    -listen_ipv6=YES
    +listen_ipv6=NO
    #
    # Allow anonymous FTP? (Disabled by default).
    -anonymous_enable=NO
    +anonymous_enable=YES
    #
    # This option should be the name of a directory which is empty.  Also, the
    # directory should not be writable by the ftp user. This directory is used
    # as a secure chroot() jail at times vsftpd does not require filesystem
    # access.
    -secure_chroot_dir=/var/run/vsftpd/empty 
    +#secure_chroot_dir=/media/usb80gb/vsftpd_chroot

なお、ホームディレクトリは /srv/ftp 配下になる。