Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22126
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 45
  • 用 户 组: 普通用户
  • 注册时间: 2014-12-05 09:43
文章分类

全部博文(8)

文章存档

2015年(8)

我的朋友

分类: LINUX

2015-07-20 23:15:39

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

参考:

阅读(640) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~