vsftpd配置虚拟用户

 

#安装vsftpd
yum -y install vsftpd

#创建本地ftp账户
groupadd ftpuser
useradd -g ftpuser -s /sbin/nologin ftpuser

#修改suselinux配置
setsebool -P ftp_home_dir on

#创建虚拟用户的账户密码文件
vi ftpusers.txt
    admin
    1234
    uploader
    1234
    downloader
    1234

#生成虚拟用户登陆时使用的认证密匙
db_load -T hash -f ftpusers.txt /etc/vsftpd/users.db

#创建vsftpd认证配置文件
vi /etc/pam.d/vsftpd.vu
    #pam_userdb.so的路径根据实际情况来
    auth    required   /lib64/security/pam_userdb.so   db=/etc/vsftpd/users
    account required   /lib64/security/pam_userdb.so   db=/etc/vsftpd/users

#禁止anonymous登录
echo "anonymous" >>/etc/vsftpd/user_list

#修改vsftpd配置
vi /etc/vsftpd/vsftpd.conf
    guest_enable=YES
    guest_username=ftpuser #该本地用户请根据实际状况来
    pam_service_name=vsftpd.vu
    user_config_dir=/etc/vsftpd/virtual_user

#创建虚拟用户的配置目录
mkdir -p /etc/vsftpd/virtual_user

#创建虚拟用户的工作目录
mkdir -p /home/ftpuser/admin
mkdir -p /home/ftpuser/uploader
mkdir -p /home/ftpuser/downloader

chmod 777 /home/ftpuser/admin
chmod 777 /home/ftpuser/uploader
chmod 777 /home/ftpuser/downloader


#单独配置虚拟用户,注意不要在配置文件多写空格!!!
vi /etc/vsftpd/virtual_user/admin
    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=/home/ftpuser/admin

vi /etc/vsftpd/virtual_user/uploader
    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=/home/ftpuser/uploader

vi /etc/vsftpd/virtual_user/downloader
    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=/home/ftpuser/downloader
    
#启动vsftpd测试吧
service vsftpd start

 

参考文章:

http://hx100.blog.51cto.com/44326/383143/
posted @ 2015-02-11 13:36  lichmama  阅读(245)  评论(0编辑  收藏  举报