CentOS5.5に vsftpd-2.3.4 をインストール

9月 18, 2023

CentOS5.5に vsftpd-2.3.4-1 をインストール

http://centos.alt.ru/repository/centos/5/i386/vsftpd-2.3.4-1.el5.i386.rpm

上記のファイルをインストールしてもSSLが無効になっているので、buildし直します。

ssl_enable=YES にして VSFTPDをスタートさせると以下のメッセージ

500 OOPS: SSL: ssl_enable set but SSL support not compiled in.

1、ソースファイルをダウンロードしてインストール
http://centos.alt.ru/pub/repository/centos/5/SRPMS/
http://centos.alt.ru/pub/repository/centos/5/SRPMS/vsftpd-2.3.4-1.el5.src.rpm

2、vsftpd-2.3.4.tar.gzを解凍して、builddefs.hを編集 ssl有効化
3、vsftpd.specはそのまま使い、ビルドします。
4、依存ファイル ビルドの際に足りない場合入れて下さい。
pam-devel
libcap-devel等他

[root@linux ~]# wget http://centos.alt.ru/pub/repository/centos/5/SRPMS/vsftpd-2.3.4-1.el5.src.rpm

[root@linux ~]# rpm -ivh vsftpd-2.3.4-1.el5.src.rpm ←インストール

[root@linux ~]# cd /usr/src/redhat/SOURCES/

vsftpd-2.3.4-1.el5.src.rpmをインストールすると/usr/src/redhat/SOURCES/に
vsftpd-2.3.4.tar.gzがあります。

[root@localhost SOURCES]# tar zxvf vsftpd-2.3.4.tar.gz ←展開


[root@linux SOURCES]# cd vsftpd-2.3.4
[root@linux vsftpd-2.3.4]# vi builddefs.h ←編集する

#ifndef VSF_BUILDDEFS_H
#define VSF_BUILDDEFS_H

#undef VSF_BUILD_TCPWRAPPERS
#define VSF_BUILD_PAM
#undef VSF_BUILD_SSL
↓
#define VSF_BUILD_SSL 変更 SSLを有効化

#endif /* VSF_BUILDDEFS_H */

[root@linux vsftpd-2.3.4]# cd .. ←ディレクトリ移動
[root@linux SOURCES]# tar czvf vsftpd-2.3.4.tar.gz vsftpd-2.3.4/ ←展開先ディレクトリ再圧縮

RPMパッケージの作成

[root@linux ~]# rpmbuild -bb --clean /usr/src/redhat/SPECS/vsftpd.spec

...........省略

伸張ファイルの検査中: /usr/lib/rpm/check-files /var/tmp/vsftpd-2.3.4-1-root-root
書き込み完了: /usr/src/redhat/RPMS/i386/vsftpd-2.3.4-1.i386.rpm
書き込み完了: /usr/src/redhat/RPMS/i386/vsftpd-debuginfo-2.3.4-1.i386.rpm
実行中(%clean): /bin/sh -e /var/tmp/rpm-tmp.42919
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd vsftpd-2.3.4
+ rm -rf /var/tmp/vsftpd-2.3.4-1-root-root
+ exit 0
実行中(--clean): /bin/sh -e /var/tmp/rpm-tmp.42919
+ umask 022
+ cd /usr/src/redhat/BUILD
+ rm -rf vsftpd-2.3.4
+ exit 0

RPMパッケージインストール

[root@linux ~]# rpm -ivh /usr/src/redhat/RPMS/i386/vsftpd-2.3.4-1.i386.rpm

サーバー証明書の作成

サーバー用証明書 有効期限を1年から10年に変更する

[root@linux ~]# cd /etc/pki/tls/certs/ ← ディレクトリ移動
[root@root@linux certs]# sed -i 's/365/3650/g' Makefile
[root@centos certs]# make vsftpd.pem ← サーバー証明書作成


umask 77 ; \
        PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
        PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
        /usr/bin/openssl req -utf8 -newkey rsa:1024 -keyout $PEM1 -nodes -x509 -days 3650 -out $PEM2 -set_serial 0 ; \
        cat $PEM1 >  vsftpd.pem ; \
        echo ""    >> vsftpd.pem ; \
        cat $PEM2 >> vsftpd.pem ; \
        rm -f $PEM1 $PEM2
Generating a 1024 bit RSA private key
...++++++
................++++++
writing new private key to '/tmp/openssl.N16647'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:JP
State or Province Name (full name) [Berkshire]:Tokyo
Locality Name (eg, city) [Newbury]:Shibuya-ku
Organization Name (eg, company) [My Company Ltd]:kencom.biz
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:ftp.kencom.biz
Email Address []:root@kencom.biz
[root@linux certs]# cd

vsftpd設定ファイル編集

[root@linux ~]# vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=NO
ascii_upload_enable=YES
ascii_download_enable=YES
#ftpd_banner=Welcome to blah FTP service.
#chroot_local_user=YES
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
ls_recurse_enable=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

use_localtime=YES
pasv_min_port=60060
pasv_max_port=60090
max_clients=20
max_per_ip=10
#convert_charset_enable=1
#local_charset=UTF8
#remote_charset=CP1251
force_dot_files=YES
text_userdb_names=YES

pasv_addr_resolve=YES
pasv_address=111.111.222.xxx

ssl_enable=YES ←SSL有効化

rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem
force_local_logins_ssl=NO
force_local_data_ssl=NO

ファイアーフォール ルーター で、TCP 20 21 ポートを開ける
PASV接続用ポート  例 TCP 60060-60090番

[root@linux ~]# /etc/rc.d/init.d/vsftpd start ← vsftpd起動
vsftpd 用の vsftpd を起動中:                       [  OK  ]
[root@linux ~]# chkconfig vsftpd on ← vsftpd自動起動設定

Linux,CentOS5.5vsftpd

Posted by admin