proftpdでLDAP認証とTLS/SSL

(1) モチベーション
proftpdを使って共有WebホスティングFTPサーバを検討する
Webコンテンツは複数ユーザで編集可能とし
ユーザ認証基盤(LDAPNISスキーマなし)のIDを使う
またCGI、SSIを許可するので
あるシステムUIDでsuEXECする必要がある
うまく編集ユーザID群をシステムUIDでグルーピングできるかがミソ
あと認証基盤のパスワードが漏れると他のサービスまで影響するので
TLS/SSLは必須

(2) まずはインストール

% ./configure --enable-openssl --enable-buffer-size --enable-pool-size --enable-scoreboard-buffer-size --enable-ipv6 --with-modules=mod_ratio:mod_readme:mod_wrap:mod_rewrite:mod_ldap:mod_tls
% make
# make install
# cp contrib/dist/rpm/proftpd.init.d /etc/init.d/proftpd

オプションで"-f /usr/local/etc/proftpd.conf"
をsysconfigあたりに書いておく

(3) 設定ファイル

----/usr/local/etc/proftpd.conf
ServerName			"ProFTPD Default Installation"
ServerType			standalone
DefaultServer			on
DefaultAddress			192.168.1.3 192.168.1.4
ServerLog			/var/log/proftpd/proftpd.log
SystemLog			/var/log/proftpd/proftpd.log
Port				0
MaxInstances			30
User				nobody
Group				nobody
UseReverseDNS			off
TLSProtocol			SSLv23
<Global>
WtmpLog				on
SyslogLevel			debug
DebugLevel			9
Umask				022
AllowOverride			off
ServerIdent			off
IdentLookups			off
AuthPAM				off
DefaultRoot			~
AllowOverwrite			on
ListOptions			"-a"
RequireValidShell		off
LDAPServer			192.168.1.1
LDAPDoAuth			on "ou=People,dc=example,dc=net" "(&(uid=%v)(objectclass=inetOrgPerson))"
LDAPForceDefaultUID		on
LDAPForceDefaultGID		on
LDAPDoUIDLookups		on "ou=People,dc=example,dc=net"
LDAPDoGIDLookups		on "ou=Group,dc=example,dc=net"
LDAPGenerateHomedir		on
LDAPGenerateHomedirPrefixNoUsername on
TLSEngine			on
TLSLog				/var/log/proftpd/tls.log
TLSRequired			on
TLSRSACertificateFile		/etc/pki/tls/certs/server.crt
TLSRSACertificateKeyFile	/etc/pki/tls/private/server.key
TLSVerifyClient			off
</Global>
Include				/usr/local/etc/proftpd.conf.d
----/usr/local/etc/proftpd.conf.d/www.example.net
<VirtualHost 192.168.1.3>
ServerName			"www.example.net"
ServerLog			/var/log/proftpd/www.example.net.log
TransferLog			/var/log/proftpd/www.example.net.log
Port				10001
LDAPDefaultUID			500
LDAPDefaultGID			500
LDAPGenerateHomedirPrefix	/home/www.example.net
<Limit All>
Order				deny,allow
DenyUser			All
AllowUser			OR hogeo,hogeko
</Limit>
</VirtualHost>
----/usr/local/etc/proftpd.conf.d/www2.example.net
<VirtualHost 192.168.1.3>
#<VirtualHost 192.168.1.4>
# VirtualHostはIPベースのみ
# ポートをかえてもよし、IPアドレスをかえてもよし
ServerName			"www2.example.net"
ServerLog			/var/log/proftpd/www2.example.net.log
TransferLog			/var/log/proftpd/www2.example.net.log
Port				10002
#Port				21
LDAPDefaultUID			501
LDAPDefaultGID			501
LDAPGenerateHomedirPrefix	/home/www2.example.net
<Limit All>
Order                           deny,allow
DenyUser                        All
AllowUser                       OR hogeo,hogemi
</Limit>
</VirtualHost>

UID 500と501、GID 500と501はFTPサーバローカルに作成する

----/etc/passwd
www.example.net:x:500:500::/home/www.example.net:/bin/bash
www.example.net:x:501:501::/home/www.example.net:/bin/bash
----/etc/group
www.example.net:x:500:
www2.example.net:x:501:

これでhogeoとhogekoはwww.example.netというUIDとして
hogeoとhogemiはwww2.example.netというUIDとして接続できる

あとは各ホスト利用者ごとにポート番号を教えるだけ

(4) 未解決
ユーザ認証基盤のLDAPはanonymous bindを許可しないのでその対応
LDAPDNInfo、LDAPAuthBindsあたりか
あとFTPサーバ <=> LDAPサーバがTLS/SSLしていない

FTPSに対応しているのがfilezillaくらい、以外とこれが致命的か(^^;;

あ、そうそう
filezillaドットファイルをみるのは
「サーバ」=>「強制的に隠しファイルを表示」