一、安装
[root@navy-test1 ~]# yum -y install vsftpd db4-utils
二、配置
1.撰写配置文件
[root@navy-test1 ~]# vi /etc/vsftpd/vsftpd.conf
anon_mkdir_write_enable=NO
anon_root=/dev/zero
anon_upload_enable=NO
anon_world_readable_only=YES
anonymous_enable=NO
banner_file=/etc/vsftpd/navy
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
chroot_local_user=YES
connect_from_port_20=YES
data_connection_timeout=120
dirmessage_enable=YES
ftpd_banner=Welcome to use navy FTP server.
guest_enable=YES
guest_username=vftp
#hide_file={.*}
pam_service_name=vsftpd.vu
idle_session_timeout=600
local_enable=YES
local_umask=022
log_ftp_protocol=YES
passwd_chroot_enable=NO
pasv_enable=YES
pasv_min_port=5000
pasv_max_port=8000
listen_ipv6=NO
listen_port=6666
listen=YES
tcp_wrappers=YES
use_localtime=YES
user_config_dir=/etc/vsftpd/userconf
userlist_enable=YES
virtual_use_local_privs=YES
write_enable=YES
xferlog_enable=YES
xferlog_std_format=YES
2.新建ftp用户账号
[root@navy-test1 vsftpd]# cat /etc/vsftpd/login.txt
ftp_up
123456
ftp_download
123456
admin
123456
3.建立db数据库
[root@navy-test1 vsftpd]# db_load -T -t hash -f /etc/vsftpd/login.txt /etc/vsftpd/login.db
[root@navy-test1 vsftpd]# chmod 0600 /etc/vsftpd/login.db
4.配置pam文件
[root@navy-test1 vsftpd]# vi /etc/pam.d/vsftpd.vu
5.建立虚拟用户对应的系统真实用户
[root@navy-test1 vsftpd]# useradd vftp -d /data/ftpdata -s /sbin/nologin
[root@navy-test1 vsftpd]# chown vftp:vftp /data/ftpdata/
6.建立虚拟用户配置文件
mkdir /etc/vsftpd/userconf
vi /etc/vsftpd/userconf/admin
write_enable=YES
anonymous_enable=NO
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
download_enable=Yes
local_root=/data/ftpdata
vi /etc/vsftpd/userconf/ftp_up
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
download_enable=NO
local_root=/data/ftpdata/ftp_up
vi /etc/vsftpd/userconf/ftp_download
write_enable=NO
anon_world_readable_only=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
local_umask=022
download_enable=yes
local_root=/data/ftpdata/ftp_download
7.新建ftp登录欢迎提示文件
vi /etc/vsftpd/navy
==== Welcome to use navy ftp server ====
Your host,ipaddress and all your operate will be logged,enjoy yourself.
8.建立添加虚拟账号的脚本
vi /etc/vsftpd/create.sh
/usr/bin/db_load -T -t hash -f /etc/vsftpd/login.txt /etc/vsftpd/login.db
/bin/chmod 0600 /etc/vsftpd/login.db
9.启动vsftp
service vsftpd start
10.加入开机启动
chkconfig vsftpd on