vsftpd 安装与虚拟用户配置

测试环境:
centos 5.X 64bit
vsftpd 2.0
安装:yum -y install vsftpd
 
需求:
虚拟三个用户,使用同一个家目录。权限如下。
ftpadmin  读写删除
ftpuser   读写
ftp       读(下载)
 
目录为:/data
密码统一为:123456
 
一、创建虚拟用户数据库:
1、创建文件文件loginuser.txt
    格式如下:
  user_id
  password
 
/home/loginuser.txt
ftpadmin
123456
ftpuser
123456
ftp
123456
 
2、生成数据库文件:
db_load -T -t hash -f /home/loginuser.txt /etc/vsftpd/vsftpd_login.db
chmod 600 /etc/vsftpd/vsftpd_login.db
 
3、配置pam文件
# vi /etc/pam.d/vsftpd.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
 
 
二、为虚拟用户创建本地系统用户
useradd opendoc -d /data -s /bin/false
chown opendoc.opendoc /data
 
三、vsftpd.conf配置
anonymous_enable=NO
local_enable=YES
#write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
listen_port=21
userlist_enable=YES
chroot_local_user=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=opendoc
pam_service_name=vsftpd.vu
user_config_dir=/etc/vsftpd/vsftpd_user_conf
virtual_use_local_privs=YES
pasv_min_port=50000
pasv_max_port=60000
pasv_enable=yes
max_clients=200
max_per_ip=4
idle_session_timeout=600
ftpd_banner=Welcome to opendoc FTP service.
 
 
mkdir /etc/vsftpd/vsftpd_user_conf
# vi /etc/vsftpd/vsftpd_user_conf/ftpadmin 所有权限
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
 
 
# vi /etc/vsftpd/vsftpd_user_conf/ftpuser 上传权限
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
 
# vi /etc/vsftpd/vsftpd_user_conf/ftp 只能下载
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
 
# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
 
测试:
# ftp -n localhost
Connected to ifidc.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
220 Welcome to tfhudong FTP service
ftp> use ftpadmin
331 Please specify the password.
Password: 
230 Login successful.
ftp> quit
221 Goodbye.
 
# ftp -n localhost
Connected to ifidc.
220 Welcome to tfhudong FTP service
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
ftp> use ftpuser
331 Please specify the password.
Password: 
230 Login successful.
ftp> quit
221 Goodbye.
 
# ftp -n localhost              
Connected to ifidc.
220 Welcome to tfhudong FTP service
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
ftp> use ftp
331 Please specify the password.
Password: 
230 Login successful.
ftp> quit
221 Goodbye.


本文转自守住每一天51CTO博客,原文链接:http://blog.51cto.com/liuyu/333172,如需转载请自行联系原作者

上一篇:Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE解决方法


下一篇:zigbee协议学习(一)