|
Contributed at: 2004/11/18 (Thu) 14:34
|
Fedora Core 3 付属の vsftpd の chroot 方法。chroot 設定とは、ホームディレクトリより上位に移動させなくすることで、セキュリティを高める方法。たとえば /home/hoheoe がホームディレクトリであれば、FTP 接続後のディレクトリは通常 /home/hoehoe です。けれども、chroot 設定をすると、FTP 接続語の /home/hoehoe が【 / 】となって表示され、上位のディレクトリへのアクセスを禁止させることができます。
# ftp 192.168.11.253
Connected to 192.168.11.253 (192.168.11.253).
220 (vsFTPd 2.0.1)
Name (192.168.11.253:zem): zem
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/zem"
これは通常の初期設定。zem アカウントのホームディレクトリが /home/zem のため、【 pwd 】で現在場所を調べると【 /home/zem 】になっている事がわかる。
設定変更方法は設定ファイル /etc/vsftpd/vstpd.conf の変更が必要。96,99 行目を変更する。
# 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(chroot 設定を有効にする)
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list(chroot 設定を有効にするユーザを指定するファイル)
# diff -u vsftpd.conf.2004-1118 vsftpd.conf
--- vsftpd.conf.2004-1118 2004-10-04 15:36:48.000000000 +0900
+++ vsftpd.conf 2004-11-18 14:14:52.052021024 +0900
@@ -93,9 +93,9 @@
# 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
+chroot_list_enable=YES
# (default follows)
-#chroot_list_file=/etc/vsftpd.chroot_list
+chroot_list_file=/etc/vsftpd.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
次に【 /etc/vsftpd.chroot_list 】を開き、chroot 設定をしたいユーザ名を記述する。このファイルにユーザ名を書かないと有効にならない(ProFTPD であればグループ単位で制限ができたが=DefualtRoot ~ users と記述すると users グループは纏めて chroot、この点 vsftpd は面倒……)
vsftpd.conf の設定を変更したので、vsftpd デーモンを再起動して設定を確認する。
# /etc/rc.d/init.d/vsftpd restart
vsftpd を停止中: [ OK ]
vsftpd 用の vsftpd を起動中: [ OK ]
あとは、ftp をして、実際に pwd を実行して chroot(ホームディレクトリより上位に移動できない)を確認。
# ftp 192.168.11.253zem
ftp: 192.168.11.253zem: Name or service not known
ftp> [root@linux zem]# ftp 192.168.11.253
Connected to 192.168.11.253 (192.168.11.253).
220 (vsFTPd 2.0.1)
Name (192.168.11.253:zem): zem
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 >"/"
【 / 】と ftp 上で表示されているが、操作している実体はあくまでも【 /home/アカウント名/ 】配下。
chroot 設定があれば、不用意に一般ユーザが /etc/ にアクセスさせたり、サーバの設定ファイルを参照してセキュリティをおとす事にならないので、安全。
[分類 /linux/FedoraCore3 ]
固定リンク
| |
|