安装ftp和Berkeley DB工具
# yum -y install vsftpd
# yum -y install db4-utils
#vim /etc/vsftpd/user.txt //创建密码文件,奇数行为用户名,偶数行为密码
itomb
itombpwd
yagm
yagmpwd
#db_load -T -t hash -f user.txt /etc/vsftpd/user.db
#cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
#vim /etc/pam.d/vsftpd
注释掉vsftp里所有内容,添加如下
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/user
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/user
ps:我这是64为centos,根据自己情况来添加pam_userdb.so路径
配置vsftpd配置文件(这里是我的配置文件)
# cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
listen=YES
connect_from_port_20=YES
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=50100
xferlog_enable=YES
xferlog_std_format=NO
xferlog_file=/var/log/vsftpd.log
pam_service_name=vsftpd
userlist_enable=YES
chroot_list_enable=YES
guest_enable=YES
guest_username=www
user_config_dir=/etc/vsftpd/user_conf
ftpd_banner=Welcome to blah FTP service
tcp_wrappers=YES
reverse_lookup_enable=NO
#touch /etc/vsftpd/chroot_list
#echo www >>/etc/vsftpd/chroot_list
#mkdir /etc/vsftpd/user_conf/
#vim /etc/vsftpd/user_conf/itomb
local_root=/data/htdocs/itomb
//虚拟用户的根目录,这里内容结尾地方不能有空格
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
#mkdir /data/htdocs/itomb
#chown www:www /data/htdocs/itomb
#/etc/init.d/vsftpd restart
#iptables -A INPUT -p tcp --dport 20 -j ACCEPT
#iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#iptables -A INPUT -p tcp --dport 50000:50100 -j ACCEPT
ps:这里的50000到50100是ftp的随机端口,在配置文件里设置上限下限,然后在防火墙里开启这段端口即可,否则会造成访问ftp的各种问题
虚拟用户权限
1.所有权限
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/user1
2.上传权限
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/user2
3.下载权限
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/user3
虚拟用户高级设置
1、virtual_use_local_privs参数
当virtual_use_local_privs=YES时,虚拟用户和本地用户有相同的权限
当virtual_use_local_privs=NO时,虚拟用户和匿名用户有相同的权限,默认是NO。
当virtual_use_local_privs=YES,write_enable=YES时,虚拟用户具有写权限(上传 下载 删除 重命名)
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=YES anon_upload_enable=YES时,虚拟用户不能浏览目录,只能上传文件,无其他权限。
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_upload_enable=NO时,虚拟用户只能下载文件,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_upload_enable=YES时,虚拟用户只能上传和下载文件,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_mkdir_write_enable=YES时,虚拟用户只能下载文件和创建文件夹,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_other_write_enable=YES时,虚拟用户只能下载、删除和重命名文件,无其他权
只能删,不能传
virtual_use_local_privs=NO
write_enable=YES
anon_world_readable_only=NO
anon_other_write_enable=YES
local_umask=022
download_enable=Yes
local_root=/data/user4
# yum -y install vsftpd
# yum -y install db4-utils
#vim /etc/vsftpd/user.txt //创建密码文件,奇数行为用户名,偶数行为密码
itomb
itombpwd
yagm
yagmpwd
#db_load -T -t hash -f user.txt /etc/vsftpd/user.db
#cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
#vim /etc/pam.d/vsftpd
注释掉vsftp里所有内容,添加如下
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/user
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/user
ps:我这是64为centos,根据自己情况来添加pam_userdb.so路径
配置vsftpd配置文件(这里是我的配置文件)
# cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
listen=YES
connect_from_port_20=YES
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=50100
xferlog_enable=YES
xferlog_std_format=NO
xferlog_file=/var/log/vsftpd.log
pam_service_name=vsftpd
userlist_enable=YES
chroot_list_enable=YES
guest_enable=YES
guest_username=www
user_config_dir=/etc/vsftpd/user_conf
ftpd_banner=Welcome to blah FTP service
tcp_wrappers=YES
reverse_lookup_enable=NO
#touch /etc/vsftpd/chroot_list
#echo www >>/etc/vsftpd/chroot_list
#mkdir /etc/vsftpd/user_conf/
#vim /etc/vsftpd/user_conf/itomb
local_root=/data/htdocs/itomb
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
#mkdir /data/htdocs/itomb
#chown www:www /data/htdocs/itomb
#/etc/init.d/vsftpd restart
#iptables -A INPUT -p tcp --dport 20 -j ACCEPT
#iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#iptables -A INPUT -p tcp --dport 50000:50100 -j ACCEPT
ps:这里的50000到50100是ftp的随机端口,在配置文件里设置上限下限,然后在防火墙里开启这段端口即可,否则会造成访问ftp的各种问题
虚拟用户权限
1.所有权限
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/user1
2.上传权限
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/user2
3.下载权限
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/user3
虚拟用户高级设置
1、virtual_use_local_privs参数
当virtual_use_local_privs=YES时,虚拟用户和本地用户有相同的权限
当virtual_use_local_privs=NO时,虚拟用户和匿名用户有相同的权限,默认是NO。
当virtual_use_local_privs=YES,write_enable=YES时,虚拟用户具有写权限(上传 下载 删除 重命名)
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=YES anon_upload_enable=YES时,虚拟用户不能浏览目录,只能上传文件,无其他权限。
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_upload_enable=NO时,虚拟用户只能下载文件,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_upload_enable=YES时,虚拟用户只能上传和下载文件,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_mkdir_write_enable=YES时,虚拟用户只能下载文件和创建文件夹,无其他权限
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO anon_other_write_enable=YES时,虚拟用户只能下载、删除和重命名文件,无其他权
只能删,不能传
virtual_use_local_privs=NO
write_enable=YES
anon_world_readable_only=NO
anon_other_write_enable=YES
local_umask=022
download_enable=Yes
local_root=/data/user4