ftpサーバの構築
| vsftpdとwu-ftpdについて説明します。 最初にvsftpdについて、 #] vi /etc/vsftpd.conf |
| # Example config file /etc/vsftpd.conf # # The default compiled in settings are very paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # # Allow anonymous FTP? anonymous_enable=YES ←YESをNOにする # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/vsftpdd.log # # If you want, you can have your log file in standard ftpd xferlog format xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. # nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. # async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that turning on ascii_download_enable enables malicious remote parties # to consume your I/O resources, by issuing the command "SIZE /big/file" in # ASCII mode. # These ASCII options are split into upload and download because you may wish # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking), # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be # on the client anyway.. # ascii_upload_enable=YES # ascii_download_enable=YES # # You may fully customise the login banner string: # ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. # deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpdd.banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # chroot_list_enable=YES ←#をとる # (default follows) # chroot_list_file=/etc/vsftpdd.chroot_list ←#をとる # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. # ls_recurse_enable=YES pam_service_name=vsftpd |
| anonymous_enable=NO ←YES から NO にする ここの設定変更はアノニマス(匿名)をこのFTPサーバにログインできなくする設定です。 初期状態ではYESになっていて、世界中のだれでもが貴方のサーバに勝手にアクセスしてログインできてしまう設定です。今構築しているサーバでは不特定の第3者にプログラム配布をするなどといった目的は一切ありませんから、ここでは、アノニマス(匿名)さん達からのアクセスはできないようします。 このサーバのユーザーとして登録されている人達が貴方のサーバにFTP接続でログインすると、ユーザーの本来ログインできるディレクトリ(/home/ユーザー)以外のどこにでも$cdコマンドで移動できてしまいます。下記設定で登録ユーザーのホームディレクトリ(/home/ユーザー)以外への移動を不可能にします。 指定されたディレクトリよりも上の階層にいけなくすること=チェンジルート(chroot) chroot_list_enable=YES ←#をとる # (default follows) chroot_list_file=/etc/vsftpd.chroot_list ←#をとる #chrootリストの使用を可能にする #chrootのリストファイルは/etcディレクトリにあるchroot_listとする 最初は/etcディレクトリにあるvsftpd.chroot_listファイルが存在していませんから、新たに作製する必要があります。そして作製されたvsftpd.chroot_listファイルにユーザーのアカウントを登録していきます。逆に管理上の必要性からwebmasterやadminなどの特別なユーザーは登録しないでおきます。 # touch /etc/vsftpd.chroot_list ←ファイル名vsftpd.chroot_listが新規作製されます または # vi /etc/vsftpd.chroot_list ここにユーザーのアカウントを登録してから保存します。 管理上の必要性からadminやwebmasterなど特別なユーザーは登録しないでおきます。 wu-ftpdについて説明します。 RedHat Linuxの以前のバージョンの7.3では初期搭載FTPサーバwu-ftpdというものがありました。こちらはvsftpdとは正反対でディレクトリ階層を自由に行き来出来るユーザーのみ登録するタイプですので、大量のユーザーを抱える場合には管理が非常に楽になります。このwu-ftpdの以前のバージョンにセキュリティー上の問題があり何かと物議を醸したのですが、現在のバージョンでは改善されていますので使用に問題は無いようです。RedHat Linux8.0のインストールディスクにもしっかり収録されていますので、こちらをインストールして使用しても良いでしょ。 wu-ftpdはインストールCDの3枚目に収録されています。 3枚目のCDをCDROMにセットします。 |
| # mount /mnt/cdrom # rpm -ihv /mnt/cdrom/RedHat/RPMS/wu-ftpd-2.6.2-8.i386.rpm 警告: wu-ftpd-2.6.2-8.i386.rpm: v3 DSA signature: NOKEY, KEY ID db42a60e preparing・・・ ########################################### 100% 1:wu-ftpd ########################################### 100% |
| wu-ftpdをインストールしますと、起動設定ファイルはvsftpdと同じく/etc/xinetd.d内に作られますので、これまた同様に編集してxinetdを再起動して下さい。そのおり、vsftpの起動設定ファイルはyesに戻して停止させて下さい。また、サーバの起動時からのサービス開始設定でも# ntsysvコマンドでvsftpを停止、wu-ftpdを開始設定しておくことをお忘れなく。 wu-ftpdの作動設定ファイルは/etc/ftpaccessです。エディタで編集します。 |
| # vi /etc/ftpaccess # Chroot all users to their home directory by default # (comment this out if you don't want to chroot most of your users) guestuser * # If you wish to allow user1 and user2 to access other # directories, use the line below: # realuser user1,user2 |
| guestuser * これで全てのユーザーがチェンジルートされています、*(アスタリスク)することで全ての登録ユーザーを指し示しています。 しかしこれでは、管理上不都合ですので特定の管理者や管理者グループを解除します。 realgroup admins realuser admin webmaste その他ログインできるユーザークラスとして |
|
# User classes... |
| 上記のguestを削除しておいて下さい。これを忘れると一般の登録ユーザーがFTPクライアントを使用して自ディレクトリ内のファイルのパーミッション変更をしようとしても、アノニマスさん同様に禁止された状態になってしまってCGIなどが動かせなくなってしまいます。 最後にこのwu-ftpdはセキュリティーで問題になったのでバージョン番号などもなるべくは隠したいところです。本ファイルの最後に以下を書き足して下さい。バージョン番号が非表示になります。 greeting terse 以上でFTPサーバの設定は完了しました。 |