Installation.
yum install - y vsftpd db4 db4-cxx db4-devel db4-utils
`which useradd` vftpuser - d /data/ftpdata - s /sbin/nologin
cd /etc/vsftpd/
cat >>vuser.txt<<EOF
vftpuser
vftpuser_passwd
EOF
db_load -T - t hash - f vuser.txt vuser.db4
cat >>/etc/pam. d/vsftpd. vu<<EOF
auth required /lib64/security/pam_userdb. so db=/etc/vsftpd/vuser
account required /lib64/security/pam_userdb. so db=/etc/vsftpd/vuser
EOF
Configuration./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=YES
idle_session_timeout=300#
data_connection_timeout=2#
accept_timeout=5#
connect_timeout=1#
async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to wljiashi FTP service.
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
listen_port=21
pam_service_name=vsftpd.vu #
userlist_enable=NO
tcp_wrappers=YES
guest_enable=YES
guest_username=vftpuser
virtual_use_local_privs=YES
local_max_rate=2097152
use_localtime=YES
#user_config_dir=/etc/vsftpd/vconf
pasv_min_port=30020#
pasv_max_port=30220#
注意配置文件中后面带#行,timeout部分如果不添加的话,在上传大文件或者很多文件时会卡死!
观察lsof -i:21和netstat -luntp|grep tcp会粗线很多的TIME WAIT或者是CLOSE WAIT
google了下貌似是vsftpd的通病(proftp也会…)
另外如果本机有开启防火墙的话,/etc/sysconfig/iptables-config里IPTABLES_MODULES=""=>IPTABLES_MODULES="ip_conntrack_ftp"是防火墙启动时自动加载ftp模块。
另外需添加添加防火墙规则-A INPUT -m state --state NEW -m tcp -p tcp --dport 30020:30220 -j ACCEPT
--转自
该贴由koei123转至本版2015-6-1 15:09:20