| *講義内容
サーバ導入に関しての考察とレンタルサーバホスティングとの比較
サーバの選定と回線・ISP選択とドメインの準備
OSのインストール (RedHat Linux8.0)
How to
PC-Unix(Linux) 超簡素UNIX入門講座
基本システム構築編
第一教程 ネットワークの設定
第二教程 DNSサーバの設定
第三教程 メールサーバの設定
第四教程 Webサーバの設定
第五教程 FTPサーバの設定
第六教程 時刻の同期(NTPD)設定
各種用途に答える システム拡張編
第七教程 DHCPとIPマスカレード設定
第八教程 プロキシサーバ設定
第九教程
バーチャルホスティング ・IPベースとネームベース ・サブドメイン
第十教程 ハードディスクの割当容量を制限する
基本運用管理編
第一教程 ユーザとグループの管理 (登録と削除)
第二教程 システムのアップデート
第三教程 管理コマンドとログ解析
以後順次公開予定
|
■FTPサーバの設定 vsftpdの設定ファイルの編集
《教程の目的と作業のポイント》
FTP(ファイル・トランスポート・プロトコル)サーバは既にメールサーバのPOPサーバの起動設定のおり、一緒に起動設定を済ませて現在は起動中のはずです。ここではこのFTPサーバの設定ファイルを編集します。
この編集作業により匿名の第3者からのFTPサーバへのアクセスを拒否したり、登録ユーザーが自分のディレクトリ以外は移動出来なくする(チェンジルート)などの基本設定をします。
ところでこのFTPサーバて、何者なのでしょうか?DNS、WEB(WWW)、MAILとそれぞれ機能・役目の解り易いサーバが続いてきてインターネットサーバの基幹サーバたる最後がこのFTPサーバですが、どうもその存在がぱっとしません。このFTPサーバは読んで字の如しでファイルをやり取りする為のサーバ(アップロードとダウンロード)でして、これが無いと例えばWEBサーバで表示されるべきホームページのHTMLデータなども肝心のサーバの保存しておくべきディレクトリにお手元のパソコンなどから転送できなくなってしまいます。つまり、今、この講座のこのページなどもFTPサーバが稼動していないと、いちいちサーバで保存されるべきディレクトリに入って、そこで作製しなければならなくなってしまいます、現実的にはこれでは話になりません。FTPと聞きますとアノニマス・サーバをイメージして無料プログラムなどを配布してくれるインターネット上のプログラム宅配屋さんのイメージが強いのですが、実は縁の下の力持ち、インターネットサーバの黒子的存在で、これなくしてはインターネットサーバは成り立たない重要なサーバなのですね。さて、ここではRedHat Linux8.0の初期設定でインストールされるvsftpdサーバの設定を行いますが、それ以前のバージョンでデフォルトインストールのFTPサーバでしたwu-ftpdの設定にも若干ふれます。
|
ここでの編集対象のファイルは/etc/vsftpd.confです。
最初に、編集対象のファイルの原本をコピーして、何かの時に初期設定の確認などができるように原本のファイルを保存してから編集作業に入ります。
尚、メールサーバの設定を飛ばしてここに来てしまった人は一度メールサーバの設定の該当部分に目を通しvsftpdを起動させておいてから、この先に進んで下さい。
下記の様に順番に進めて下さい。
$ su - ← rootに変身します
# cd /etc ← /etcディレクトリに移動します
# ls ←目的のファイルの存在を確かめて下さい
# cp vsftpd.conf vsftpd.conf.bak
↑ ファイル名+.bakという名前を付加して原本をコピーします
# ls
↑ちゃんとvsftpd.conf.bakいう名前のファイルが出来ているか確認します
# pico vsftpd.conf ←ピコエディタで原本を開き編集作業に入ります
この設定ファイルには接続ポートの設定、ログ(接続記録)の取得内容の変更やオプション追記で転送レートの設定などさまざま設定ができます、とりあえずは不特定多数の匿名第3者のアクセスを拒否し、ユーザーが自ディレクトリ以外には移動できない様に下記のピンク色の部分を編集します。
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
|
# Allow anonymous FTP?
anonymous_enable=NO ←YES から NO
ここの設定変更はアノニマス(匿名)をこのFTPサーバにログインできなくする設定です。初期状態ではYESになっていて、世界中のだれでもが貴方のサーバに勝手にアクセスしてログインできてしまう設定です。だからといって特別危険ではありませんが、「おお!接続できるぞ!」などと世界中の誰彼と無くアクセスされたらたまりません。今構築しているサーバでは不特定の第3者にプログラム配布をするなどといった目的は一切ありませんから、ここはしっかりとアノニマスさん達を排除しましょう。
じっさいに変更前には、
$ ftp example.co.jp
Connected to example.co.jp (192.168.100.3).
220 ready, dude (vsftpdd 1.1.0: beat me, break me)
Name (ftp.example.co.jp:test): anonymous
331 Please specify the password.
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> exit
このようにアノニマスさんがちゃっかりと貴方のサーバの/var/ftpディレクトリにログインしています。
≪参考≫
コンソールでのFTPログインの仕方は上記の様にします。試しにやってみて下さい。
(ご自身のサーバの場合はadminなどと正規のアカウントを使ってログインします)
FTPコマンドで、
$ ftp example.co.jp ←IPアドレスでもOK $ ftp 192.168.100.3
お名前は?と聞かれますから
Name (ftp.example.co.jp:test): アノニマスと申します。(貴方のサーバの場合は登録アカウントである、adminでも結構です)続けてパスワードを聞かれますので、
Password:(架空でもOK)メール@アドレス入力(実際は表示されません)
(adminなどの場合は真実のパスワードを入力します)
その後はls cd pwdなどのお馴染みのコマンドが使用出来ます。
実際にファイルなどをダウンロードする場合は、ここで
>get ファイル名 とします。
ログアウトする場合は、
ftp> exit 又はftp> byeとします。
変更後は、
$ ftp ftp.example.co.jp
Connected to ftp.example.co.jp (192.168.100.3).
220 ready, dude (vsftpdd 1.1.0: beat me, break me)
Name (ftp.example.co.jp:test): anonymous
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
ftp> exit
221 Goodbye.
ちゃんと追い払われています! |
さらにvsftpdの設定は続きます・・・・・・
|
|