1.生成虚拟用户口令库文件。为了建立此口令库文件,先要生成一个文本文件。该文件的格式如下,单数行为用户名,偶数行为口令:
#vi account.txt
lhq
1234
2.生成口令库文件,并修改其权限:
#db_load -T -t hash -f ./account.txt /etc/vsftpd/account.db
#chmod 600 /etc/vsftpd/account.db
3.新建一个虚拟用户的PAM文件。加上如下两行内容:
#vi /etc/pam.d/vsftp.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/account
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/account
4.建立虚拟用户,设置该用户所要访问的目录,并设置虚拟用户访问的权限:
#useradd -d /home/ftpsite virtual_user
#chmod 700 /home/ftpsite
5.编辑/etc/vsftpd/vsftpd.conf文件,使其整个文件内容如下所示(去掉了注释内容):
anonymous_enable=NO
local_enable=YES
local_umask=022
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
one_process_model=NO
chroot_local_user=YES
ftpd_banner=Welcom to my FTP server.
anon_world_readable_only=NO
guest_enable=YES
guest_username=virtual_user
pam_service_name=vsftp.vu
user_config_dir=/etc/vsftpd/vsftpd_user
6.重新启动VSFTP:
#service vsftpd restart
7. 配置虚拟用户权限
#vi /etc/vsftpd/vsftpd_user/lhq
local_root=/home/ftpsite/lhq
anon_world_readable_only=no
write_enable=yes
anon_upload_enable=yes
anon_other_write_enable=yes
anon_mkdir_write_enable=yes
#vi account.txt
lhq
1234
2.生成口令库文件,并修改其权限:
#db_load -T -t hash -f ./account.txt /etc/vsftpd/account.db
#chmod 600 /etc/vsftpd/account.db
3.新建一个虚拟用户的PAM文件。加上如下两行内容:
#vi /etc/pam.d/vsftp.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/account
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/account
4.建立虚拟用户,设置该用户所要访问的目录,并设置虚拟用户访问的权限:
#useradd -d /home/ftpsite virtual_user
#chmod 700 /home/ftpsite
5.编辑/etc/vsftpd/vsftpd.conf文件,使其整个文件内容如下所示(去掉了注释内容):
anonymous_enable=NO
local_enable=YES
local_umask=022
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
one_process_model=NO
chroot_local_user=YES
ftpd_banner=Welcom to my FTP server.
anon_world_readable_only=NO
guest_enable=YES
guest_username=virtual_user
pam_service_name=vsftp.vu
user_config_dir=/etc/vsftpd/vsftpd_user
6.重新启动VSFTP:
#service vsftpd restart
7. 配置虚拟用户权限
#vi /etc/vsftpd/vsftpd_user/lhq
local_root=/home/ftpsite/lhq
anon_world_readable_only=no
write_enable=yes
anon_upload_enable=yes
anon_other_write_enable=yes
anon_mkdir_write_enable=yes