ProFTPd

ProFTPd は Apache に似たディレクトリの制御を取る FTPd です.設定が簡単で見通しよいため使用しております.当サーバでは, netfilter により内向きのみで運用しています.

インストール

適当なところから,ソースを拾ってきます.2004/01/10 現在 1.2.9 が最新です.ProFTPd のサイトは http://proftpd.linux.co.uk/ です.

 
# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.9.tar.bz2
# tar xvjf proftpd-1.2.9.tar.bz2
# cd proftpd-1.2.9
適当にコンフィグオプションに目を通す
# ./configure --help
今回は特になさそうなので prefix のみの指定
# ./configure --prefix=/usr/local/proftpd
# make
# make install

コンフィグ

上記のコンフィグの場合,/usr/local/proftpd/etc/proftpd.conf にファイルが存在します.今回はユーザのみログインできるようにして,Anonymous はログイン禁止とします.書くディレクティブは http://www.infoscience.co.jp/technical/proftpd/reference.html (日本語) http://proftpd.linux.co.uk/localsite/Userguide/linked/ref-directives.html (英語)に詳細に記載されています.

 
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

#ServerName                     "ProFTPD Default Installation"
# デフォルトではかっこ悪いので適当に変えます.
# 別に FQDN でもなくても OK
ServerName                      "ftp.m9841.info"
# inetd 経由で起動するなら,inetd にして /etc/inetd.conf に
# ftp stream tcp nowait root /usr/local/proftpd/sbin/proftpd proftpd
# を追加するべし.
ServerType                      standalone
# DefaultServer はオンにしておく
# 解説をみるべし
DefaultServer                   on

# リモートのユーザ名は別にわからなくてもいいのでオフ
IdentLookups off

# Port 21 is the standard FTP port.
Port                            21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask                           022

# Set timezone to JST
# GMT のままだと時間が狂うのでオフにしておく
TimesGMT Off

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30

# Set the user and group under which the server will run.
User                            nobody
# Vine には標準で nogroup がなくて,nobody である
#Group                          nogroup
Group                           nobody

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
# デフォルトのディレクトリをユーザのホームとしてかつ,
# グループが users のみを許可
DefaultRoot ~ users

# Normally, we want files to be overwriteable.
<Directory />
  AllowOverwrite                on
</Directory>

# Login setting
<Limit LOGIN>
  Order allow,deny
  Allow from 192.168.1.0/24
  Deny from all
</Limit LOGIN>

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous ~ftp>
  User                          ftp
  Group                         ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"
  UserAlias                     anonymous ftp

  # Limit the maximum number of anonymous logins
  MaxClients                    10

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin                  welcome.msg
  DisplayFirstChdir             .message

  # Limit Login anonymous
  <Limit LOGIN>
  DenyAll
  </Limit LOGIN>

  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>

# Log config
LogFormat auth "%v [%P] %h %t \"%r\" %s"

# 適当にログをつける
TransferLog /usr/local/proftpd/var/log/proftpd_xferlog
ExtendedLog /usr/local/proftpd/var/log/proftpd_access_log WRITE,READ
ExtendedLog /usr/local/proftpd/var/log/proftpd_auth_log AUTH auth

起動スクリプト

Vine の SRPM からパクってきて適当に改造.ProFTPd-init
ポイントは,PATHに/usr/local/proftpd/sbin を追加し,FTPSHUT を /usr/local/proftpd/sbin/ftpshut に変更するくらいです.

自動起動

お決まりのパターン

 
# cp proftpd-init /etc/init.d/
# chkconfig --add proftpd
# chkconfig --level 2345 proftpd on
# /etc/init.d/proftpd start

ログのローテイト

LAN 内の閑散とした FTPd ですが,とりあえずログを廻しておきます.proftpd-logrotate