vsftpd虚拟用户配置(文本模式)

有服务器方面的问题无法解决?点击这里寻求帮助。

文章目录
[隐藏]

1、安装vsftpd

  1. yum install db4-utils db4 vsftpd

2、创建虚拟用户数据库

  1. cd /etc/vsftpd
  2. vi vusers.txt

内容如下:

  1. vivek
  2. vivekpass
  3. sayali
  4. sayalipass

现在创建数据库:

  1. db_load -T -t hash -f vusers.txt vsftpd-virtual-user.db
  2. chmod 600 vsftpd-virtual-user.db vusers.txt

3、配置vsftpd以支持虚拟用户

  1. anonymous_enable=NO
  2. local_enable=YES
  3. # Virtual users will use the same privileges as local users.
  4. # It will grant write access to virtual users. Virtual users will use the
  5. # same privileges as anonymous users, which tends to be more restrictive
  6. # (especially in terms of write access).
  7. virtual_use_local_privs=YES
  8. write_enable=YES
  9.  
  10. # Set the name of the PAM service vsftpd will use
  11. # RHEL / centos user should use /etc/pam.d/vsftpd
  12. pam_service_name=vsftpd.virtual
  13.  
  14. # 激活虚拟用户
  15. guest_enable=YES
  16.  
  17. # Automatically generate a home directory for each virtual user, based on a template.
  18. # For example, if the home directory of the real user specified via guest_username is
  19. # /home/virtual/$USER, and user_sub_token is set to $USER, then when virtual user vivek
  20. # logs in, he will end up (usually chroot()'ed) in the directory /home/virtual/vivek.
  21. # This option also takes affect if local_root contains user_sub_token.
  22. user_sub_token=$USER
  23.  
  24. # 设置虚拟用户根目录
  25. local_root=/home/vftp/$USER
  26.  
  27. # Chroot user and lock down to their home dirs
  28. chroot_local_user=YES
  29.  
  30. # Hide ids from user
  31. hide_ids=YES

4、创建PAM文件

  1. vi /etc/pam.d/vsftpd.virtual

内容如下:

  1. #%PAM-1.0
  2. auth       required     pam_userdb.so db=/etc/vsftpd/vsftpd-virtual-user
  3. account    required     pam_userdb.so db=/etc/vsftpd/vsftpd-virtual-user
  4. session    required     pam_loginuid.so

5、创建相关目录

  1. # mkdir /home/vftp
  2. # mkdir -p /home/vftp/{vivek,sayali}
  3. # chown -R ftp:ftp /home/vftp

6、重启vsftpd

  1. service vsftpd restart

参考:http://www.cyberciti.biz/tips/centos-redhat-vsftpd-ftp-with-virtual-users.html

转载请保留原文链接:Linux运维日志 » vsftpd虚拟用户配置(文本模式)

打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. jerry.jin您好,博主 我按照i的做法做了,但最后却又报错 [root@localhost ~]# /etc/init.d/vsftpd restart Shutting down vsftpd: [FAILED] Starting vsftpd for vsftpd: 500 OOPS: missing value in config file for: [FAILED] [root@localhost ~]#回复