1、安装vsftpd
yum install vsftpd db4-utils -y
2、修改vsftpd.conf文件
# Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. anonymous_enable=NO local_enable=YES local_umask=022 write_enable=YES dirmessage_enable=NO xferlog_enable=YES xferlog_std_format=YES dual_log_enable=YES vsftpd_log_file=/var/log/vsftpd.log connect_from_port_20=YES idle_session_timeout=600 #data_connection_timeout=120 chroot_local_user=YES listen=YES pam_service_name=ftp.vuser userlist_enable=YES tcp_wrappers=YES max_clients=10 max_per_ip=0 user_config_dir=/etc/vsftpd/vusers virtual_use_local_privs=YES #如使用被动模式使用添加以下选项 pasv_enable=YES pasv_min_port=65400 pasv_max_port=65410
3、创建/etc/vsftpd/vusers目录,用于存放虚拟用户配置文件
mkdir /etc/vsftpd/vusers
4、创建/etc/pam.d/ftp.vuser文件,添加以下内容
vi /etc/pam.d/ftp.vuser auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login #/etc/vsftpd/vsftpd_login文件为生成的db文件,不需要添加后缀名
5、创建ftp虚拟用户文件并生成db文件
vi /etc/vsftpd/vsftpd_login.txt ftp1 #用户名 123456 #密码 ftp2 #用户名 123456 #密码
#生成db文件,执行以下命令
db_load -T -t hash -f /etc/vsftpd/vsftpd_login.txt /etc/vsftpd/vsftpd_login.db
6、创建虚拟用户配置文件,文件名必须与ftp虚拟用户名一致
vi /etc/vsftpd/vusers/ftp1 guest_enable=YES #开启虚拟账号支持 guest_username=www #映射的本地用户账号,www的家目录必须为ftp根目录的上级目录 local_root=/home/wwwroot/web1 #虚拟用对应的ftp根目录,该目录需要映射的本地用户账号的对应权限 write_enable=YES #允许写入
7、重启vsftpd
service vsftpd restart
另附创建虚拟用户脚本http://3802230.blog.51cto.com/3792230/1412310
转载于:https://blog.51cto.com/3802230/1412311