Centos6.4(32位)vsftpd的安装与配置
一、允许匿名方式登录ftp服务器的配置
1.安装
#yum �Cy install vsftpd* pam* db4*
2.修改主配置文件vsftpd.conf
anonymous_enable=YES
anon_upload_enable=yes
anon_mkdir_write_enable=yes
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
ftpd_banner=Welcometo MYFTP service
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd.log
idle_session_timeout=300
data_connection_timeout=120
ascii_upload_enable=YES
ascii_download_enable=YES
listen=YES
chroot_local_user=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
3.启动vsftpd
#service vsftpd start
4.在windowns-xp客户端
说明vsftpd服务可以匿名登录,注:这里使用的是默认用户,账号和密码均为ftp
二、禁止匿名用户登录,虚拟用户使用vsftpd服务器登录的配置,具体操作如下:
#vi virtual_user_login
web1
123456
tzf
abcd1234
#db_load-T -t hash -f virtual_user_login/etc/vsftpd/virtual_user_login.db
#chmod600 /etc/vsftpd/virtual_user_login.db
#useradd-d /var/wwwroot -s /sbin/nologin -g root virtual
#mkdirvirtual_user_conf
#vi /etc/vsftpd/virtual_user_conf/web1
local_root=/var/wwwroot/web1
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
#vi/etc/vsftpd/virtual_user_conf /tzf
local_root=/var/wwwroot/tzf
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
#cp /etc/pam.d/vsftpd/etc/pam.d/vsftpd.vu
#more/etc/pam.d/vsftpd.vu
文件内容显示如下,黑色加粗的字体为增加的内容:
#%PAM-1.0
auth sufficient /lib/security/pam_userdb.sodb=/etc/vsftpd/virtual_user_login
account sufficient /lib/security/pam_userdb.sodb=/etc/vsftpd/virtual_user_login
sessionoptionalpam_keyinit.soforce revoke
authrequiredpam_listfile.so item=user sense=denyfile=/etc/vsftpd/ftpusers onerr
=succeed
authrequiredpam_shells.so
authincludepassword-auth
accountincludepassword-auth
sessionrequiredpam_loginuid.so
sessionincludepassword-auth
#mkdir/var/wwwroot/web1
#mkdir/var/wwwroot/tzf
#chmod �CR777 /var/wwwroot/web1
#chmod �CR777 /var/wwwroot/tzf
#more/etc/vsftpd/vsftpd.conf
guest_enable=YES
guest_username=virtual
anonymous_enable=NO
virtual_use_local_privs=YES
file_open_mode=0777
user_config_dir=/etc/vsftpd/virtual_user_conf
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd.log
listen=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
#pam_service_name=vsftpd
pam_service_name=vsftpd.vu
userlist_enable=YES
tcp_wrappers=YES
#servicevsftpd restart
测试结果:
说明虚拟用户能正常登录,并能创建文件目录、浏览文件,配置成功
安装配置过程中遇到的问题及解决办法:
servicevsftpd start
Startingvsftpd for vsftpd: 500 OOPS: bad bool value in config file for: virtual_use_local_privs
[FAILED]
原因是:virtual_use_local_privs=YES 这一行中末尾有空格
550错误的解决办法:
以下是否解决此问题操作过程:
#sestatus-b |grep ftp
allow_ftpd_anon_writeoff
allow_ftpd_full_accessoff
allow_ftpd_use_cifsoff
allow_ftpd_use_nfsoff
ftp_home_diroff
ftpd_connect_dboff
ftpd_use_passive_modeoff
httpd_enable_ftp_serveroff
tftp_anon_writeoff
#setsebool -P ftp_disable_trans on
libsemanage.dbase_llist_set:record not found in the database (No such file or directory).
libsemanage.dbase_llist_set:could not set record value (No such file or directory).
Couldnot change boolean ftp_disable_trans
Couldnot change policy booleans
#/usr/sbin/setsebool-P ftp_home_dir 1
#sestatus -b |grep ftp
allow_ftpd_anon_writeoff
allow_ftpd_full_accessoff
allow_ftpd_use_cifsoff
allow_ftpd_use_nfsoff
ftp_home_diron
ftpd_connect_dboff
ftpd_use_passive_modeoff
httpd_enable_ftp_serveroff
tftp_anon_writeoff
#/usr/sbin/setsebool allow_ftpd_full_access 1
#/usr/sbin/setsebool allow_ftpd_use_cifs 1
#/usr/sbin/setsebool httpd_enable_ftp_server 1
#/usr/sbin/setsebool tftp_anon_write 1
#service vsftpd restart
或者输入以下命令尝试解决:
#setsebool-P ftpd_disable_trans 1
#servicevsftpd restart