vsFTPdでFTPサーバを作ろう!
ここでは、vsftpdのインストール手順を掲載しています。
vsftpdとは…?
vsftpdは"Very Secure FTPD"の略で、その名の通り、セキュリティに重点を置いたFTPサーバです。
vsftpdのインストール
[root@co ~]# yum -y install vsftpd
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.0.5-28.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vsftpd x86_64 2.0.5-28.el5 base 143 k
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 143 k
Downloading Packages:
vsftpd-2.0.5-28.el5.x86_64.rpm | 143 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd 1/1
Installed:
vsftpd.x86_64 0:2.0.5-28.el5
Complete!
vsftpdの設定
続いて設定を行います。
ここでは誰でも接続可能なAnonymous FTPではなく、ユーザごとにログイン可能なFTPサーバを構築します。
[root@co ~]# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
↓
anonymous_enable=NO
#xferlog_file=/var/log/vsftpd.log
↓
xferlog_file=/var/log/vsftpd.log
#ascii_upload_enable=YES
#ascii_download_enable=YES
↓
ascii_upload_enable=YES
ascii_download_enable=YES
#ftpd_banner=Welcome to blah FTP service.
↓
ftpd_banner=Welcome to kimamabi FTP service.
#chroot_list_enable=YES
↓
chroot_list_enable=YES
chroot_local_user=YES
#chroot_list_file=/etc/vsftpd/chroot_list
↓
chroot_list_file=/etc/vsftpd/chroot_list
#ls_recurse_enable=YES
↓
ls_recurse_enable=YES
ftpd_bannerは、FTPに接続した時に表示されるもので、自由に設定が可能です。vsftpdのバージョン情報を隠す役割もあります。
chroot_local_user=YESを追記し、chrootを有効にしておきます。
更に、設定ファイルの最後尾に以下を追記していきます。
local_root=public_html
use_localtime=YES
#パッシブ接続を行う場合、以下を追記
pasv_promiscuous=YES
pasv_min_port=64000
pasv_max_port=64029
pasv_addr_resolve=YES
#LAN内にDNSサーバを構築している場合のみ追記
pasv_address=取得した別のドメイン (kimamabi.dip.jpなど)
FTPサーバにログインしたユーザは、local_rootで設定したディレクトリよりも上の階層に進むことはできません。
pasv…は、パッシブ接続をしたい場合に追記します。FTPサーバでは通常、20番、21番ポートを使って通信を行いますが、パッシブ接続では特定のポートではなく、その他の適当なポートを用いて通信を行います。
もし、LAN内用のDNSサーバを構築している、あるいは構築する予定がある場合、サーバのグローバルアドレスが取得可能な別のドメインをpasv_addressで指定する必要があるので、ドメインが2つ必要になります。
パッシブ接続で使用するポートの範囲をpasv_min_port、pasv_max_portで設定します。
ssl_enable=YES
rsa_cert_file=/etc/pki/tls/certs/server.crt
rsa_private_key_file=/etc/pki/tls/certs/server.key
# 暗号化しない通信も許可する場合、以下を追記
force_local_logins_ssl=NO
force_local_data_ssl=NO
暗号化した通信のみ行いたい場合、force_local_logins_sslとforce_local_data_sslをYESにします。
上位層へ移動可能なユーザの登録
もしlocal_rootで設定したディレクトリよりも上の階層に進むことのできるユーザ(ここではkoro)を登録する場合、以下のようにします。
[root@co ~]# echo koro >> /etc/vsftpd/chroot_list
Exec-Shieldを無効化
Exec-Shieldが有効になっていると、vsftpdがきちんと動作しない場合があります。
そこで、vsftpdに対するExec-Shieldだけを無効化します。
[root@co ~]# execstack -q /usr/sbin/vsftpd
- /usr/sbin/vsftpd
[root@co ~]# execstack -s /usr/sbin/vsftpd
[root@co ~]# execstack -q /usr/sbin/vsftpd
X /usr/sbin/vsftpd
Xが付いていてば設定完了です。
vsftpdの起動
[root@co ~]# /etc/rc.d/init.d/vsftpd start
vsftpd 用の vsftpd を起動中: [ OK ]
[root@co ~]# chkconfig vsftpd on
[root@co ~]# chkconfig --list vsftpd
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
参考にしたサイト様
CentOSで自宅サーバー構築 - FTPサーバー構築(vsftpd)
CentOSサーバー構築マニュアル - vsftpd インストール
Red Hat Linux 9によるサーバ構築 - 3.2.2.6.FTPサーバ~vsftpd
Crimson Snow - CentOSによる自宅サーバの構築 - バッファオーバーフロー対策(Exec-Shield)
[広告]

トップページ
Rocky Linux 8
CentOS 7
Scientific Linux 6
CentOS 5
○準備
○VMware Player
○Hyper-V(Win Proのみ)
○導入
○セキュリティ対策
○Dynamic DNS
○NTPサーバ
○データベース
○WEBサーバ
○FTPサーバ
○メールサーバ
○DNSサーバ
○ファイルサーバ
○ブログシステム
○その他