−ProFTPDの設定(proftpd.confの編集)−

基本設定
先にも述べたとおり,ProFTPDの設定は,proftpd.confを直接編集して行います。
# vi /etc/proftpd.conf ←設定ファイルを開く
基本設定として以下の場所を修正します。
# This is the ProFTPD configuration file

ServerName                      Kitahotaru FTP Server ←FTPサーバの名前
ServerIdent			on "FTP Server ready."
ServerAdmin			hoge@kitahotaru.com ←管理者のメールアドレス
ServerType			standalone ←standaloneで常駐
#ServerType			inetd ←standaloneで常駐させるのでコメントアウト
DefaultServer			on
DefaultRoot                     ~ ←ユーザのホームディレクトリにchroot
AccessGrantMsg			"User %u logged in."
#DisplayConnect			/etc/ftpissue
#DisplayLogin			/etc/ftpmotd
#DisplayGoAway			/etc/ftpgoaway

# Use pam to authenticate by default
AuthPAMAuthoritative		on

# Do not perform ident lookups (hangs when the port is filtered)
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

# Chmod isn't allowed by default
#AllowChmod			on

# Default to show dot files in directory listings
LsDefaultOptions		"-a"

# See Configuration.html for these (here are the default values)
#MultilineRFC2228		off
RootLogin			off ←rootのログインは許可しない
#LoginPasswordPrompt		on
MaxLoginAttempts		3 ←何回認証の失敗を許可するか設定
#MaxClientsPerHost		none

# 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			10 ←子プロセスの最大値

# Set the user and group that the server normally runs at.
User				nobody
Group				nobody
▲UP
ディレクトリごとの設定
ProFTPDでディレクトリごとの制限を設定します。
<Directory /*>
  AllowOverwrite		on ←上書きを許可
</Directory>

<Directory /home>
  <Limit LOGIN>
    Order deny,allow
    DenyAll
    Allow from 192.168.1.0/24 ←ログインをローカルに限定
  </Limit>
</Directory>

# A basic anonymous configuration, no upload directories.
<Anonymous /var/ftp/pub> ←公開用ディレクトリの設定
  # Uncomment the following line to allow anonymous access
  #RequireValidShell		off
  #AllowChmod			off

  User				ftp
  Group				ftp
  #AccessGrantMsg		"Anonymous login ok, restrictions apply."

  # 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, '.message' displayed in
  # each newly chdired directory and tell users to read README* files. 
  DisplayLogin			welcome.msg
  DisplayFirstChdir		.message
  #DisplayReadme			README*

  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE> ←すべてのユーザの書き込みを禁止
    DenyAll 
  </Limit>
  </Anonymous>

<Directory /var/ftp/pub/incoming> ←アップロード用ディレクトリの設定
  <Limit READ WRITE> ←すべてのユーザの読み書き禁止
    DenyAll
  </Limit>
  <Limit STOR> ←ファイルを置くことを許可
    AllowAll
  </Limit>
  </Directory>
これでユーザ向け設定とanonymous ftp向け設定が完了です。ProFTPDを再起動します。
# service proftpd restart
prpftpdを停止中                       [ OK ]
proftpdを起動中                       [ OK ]
#
▲UP
その他の設定
上記でProFTPDは問題なく動きました。ただ,現在はいくらか設定を変更しています。
変更1:ユーザ向け設定の変更
WWW専用ユーザグループ(wwwgroup)をつくり,制限を追加。管理者グループ(hoge)は制限からはずし(!hogeで制限から除外),すべてのディレクトリにアクセス可とします。以下の記述はwwwgroupはpublic_htmlディレクトリにchrootし,そこから上を見ることはできません。ただし管理者グループhogeに属するユーザは,この制限をかけられないということです。
DefaultRoot                     ~/public_html wwwgroup !hoge
変更2:anonymousのアクセスを禁止
私の場合,ディレクトリを公開することも,ファイルのアップロードを受け付ける必要も今のところないので,anonymousのアクセスを禁止しました。すべてをコメントアウトしてもよかったのですが,ファイル操作制限の記述で対応しています。anonymousユーザ用設定の中に以下の記述を加えました。。
<Limit ROGIN> ←すべてのユーザのログインを禁止
    DenyAll
  </Limit>
現在はこの状態でProFTPDを動かしています。つまり,LAN内からのファイルの操作だけに使っているという状態です。そのうちセキュリティーのことが少し分かるようになれば,運用方法をゆるめていこうと思っています。
▲UP


このサイトに関するお問い合わせはlinux@kitahotaru.comまでお願いいたします。