当前位置:首页 > CentOS配置VSFTP
# users to NOT chroot(). #chroot_list_enable=YES chroot_list_enable=NO
#禁止用户登出自己的FTP主目录。 # (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list #
# You may activate the \option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as \and \assume
# the presence of the \option, so there is a strong case for enabling it. #ls_recurse_enable=YES ls_recurse_enable=NO
#禁止用户登陆FTP后使用\-R\的命令。该命令会对服务器性能造成巨大开销。如果该项被允许,那么挡多用户同时使用该命令时将会对该服务器造成威胁。
# When \directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES
#设定该Vsftpd服务工作在StandAlone模式下。顺便展开说明一下,所谓StandAlone模式就是该服务拥有自己的守护进程支持,在ps -A命令下我们将可用看到vsftpd的守护进程名。如果不想工作在StandAlone模式下,则可以选择SuperDaemon模式,在该模式下vsftpd将没有自己的守护进程,而是由超级守护进程Xinetd全权代理,与此同时,Vsftp服务的许多功能将得不到实现。 #
# This directive enables listening on IPv6 sockets. To listen on IPv4 and I
Pv6
# sockets, you must run two copies of vsftpd whith two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES
pam_service_name=vsftpd
#设定PAM服务下Vsftpd的验证配置文件名。因此,PAM验证将参考/etc/pam.d/下的vsftpd文件配置。 userlist_enable=YES
#设定userlist_file中的用户将不得使用FTP。 tcp_wrappers=YES
#设定支持TCP Wrappers。#KC: The following entries are added for supporting virtual ftp users.以下这些是关于Vsftpd虚拟用户支持的重要配置项目。默认Vsftpd.conf中不包含这些设定项目,需要自己手动添加配置。 guest_enable=YES 设定启用虚拟用户功能。 guest_username=virtusers 指定虚拟用户的宿主用户。 virtual_use_local_privs=YES
设定虚拟用户的权限符合他们的宿主用户。 user_config_dir=/etc/vsftpd/vconf
设定虚拟用户个人Vsftp的配置文件存放路径。也就是说,这个被指定的目录里,将存放每个Vsftp虚拟用户个性的配置文件,
一个需要注意的地方就是这些配置文件名必须和虚拟用户名相同。保存退出。
3.建立Vsftpd的日志文件,并更该属主为Vsftpd的服务宿主用户(这一步可以放在修改配置表前面):
[root@linuxidc.com ~]# touch /var/log/vsftpd.log
[root@linuxidc.com ~]# chown vsftpd.vsftpd /var/log/vsftpd.log
4.建立虚拟用户配置文件存放路径:
[root@linuxidc.com ~]# mkdir /etc/vsftpd/vconf/ 三.制作虚拟用户数据库文件 1.先建立虚拟用户名单文件:
[root@linuxidc.com ~]# touch /etc/vsftpd/virtusers
建立了一个虚拟用户名单文件,这个文件就是来记录vsftpd虚拟用户的用户名和口令的数据文件,
这里给它命名为virtusers。为了避免文件的混乱,我把这个名单文件就放置在/etc/vsftpd/下。
2.编辑虚拟用户名单文件:
[root@linuxidc.com ~]# vi /etc/vsftpd/virtusers ---------------------------- ftp001 123456 ftp002 123456 ftp003 123456
----------------------------
编辑这个虚拟用户名单文件,在其中加入用户的用户名和口令信息。格式很简单:“一行用户名,一行口令”。3.生成虚拟用户数据文件:
[root@linuxidc.com ~]# db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db
这里我顺便把这个命令简单说明一下
---------------------------------------------------------------------- 4.察看生成的虚拟用户数据文件
[root@linuxidc.com ~]# ll /etc/vsftpd/virtusers.db
-rw-r--r-- 1 root root 12288 Sep 16 03:51 /etc/vsftpd/virtusers.db 需要特别注意的是,以后再要添加虚拟用户的时候,只需要按照“一行用户名,一行口令”的格式将新用户名和口令添加进虚拟用户名单文件。但是光这样做还不够,不会生效的哦!还要再执行一遍“ db_load -T -t hash -f 虚拟用户名单文件虚拟用户数据库文件.db ”的上述命令使其生效才可以!
四.设定PAM验证文件,并指定虚拟用户数据库文件进行读取 1.察看原来的Vsftp的PAM验证配置文件:
[root@linuxidc.com ~]# cat /etc/pam.d/vsftpd
---------------------------------------------------------------- #%PAM-1.0
session optional pam_keyinit.so force revoke
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
auth required pam_shells.so auth include system-auth account include system-auth session include system-auth session required pam_loginuid.so
---------------------------------------------------------------- 2.在编辑前做好备份:
[root@linuxidc.com ~]# cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.backup 3.编辑Vsftpd的PAM验证配置文件
[root@linuxidc.com ~]# vi /etc/pam.d/vsftpd
---------------------------------------------------------------- #%PAM-1.0
auth required /lib/security/pam_userdb.so db=/etc/vsftpd/virtusers account required /lib/security/pam_userdb.so db=/etc/vsftpd/virtusers
共分享92篇相关文档