牛下载:绿色软件官方软件免费下载基地!
所在位置:首页 > 新闻资讯 > vsftpd虚拟用户配置(文本模式)

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

发布时间:2020-04-19 15:16:18来源:阅读:

1、安装vsftpd

yum install db4-utils db4 vsftpd

2、创建虚拟用户数据库

cd /etc/vsftpd
vi vusers.txt

内容如下:

vivek
vivekpass
sayali
sayalipass

现在创建数据库:

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

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

anonymous_enable=NO
local_enable=YES
# Virtual users will use the same privileges as local users.
# It will grant write access to virtual users. Virtual users will use the
# same privileges as anonymous users, which tends to be more restrictive
# (especially in terms of write access).
virtual_use_local_privs=YES
write_enable=YES
 
# Set the name of the PAM service vsftpd will use
# RHEL / centos user should use /etc/pam.d/vsftpd
pam_service_name=vsftpd.virtual
 
# 激活虚拟用户
guest_enable=YES
 
# Automatically generate a home directory for each virtual user, based on a template.
# For example, if the home directory of the real user specified via guest_username is
# /home/virtual/$USER, and user_sub_token is set to $USER, then when virtual user vivek
# logs in, he will end up (usually chroot()'ed) in the directory /home/virtual/vivek.
# This option also takes affect if local_root contains user_sub_token.
user_sub_token=$USER
 
# 设置虚拟用户根目录
local_root=/home/vftp/$USER
 
# Chroot user and lock down to their home dirs
chroot_local_user=YES
 
# Hide ids from user
hide_ids=YES

4、创建PAM文件

vi /etc/pam.d/vsftpd.virtual

内容如下:

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

5、创建相关目录

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

6、重启vsftpd

service vsftpd restart

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

反对
收藏
  • 热门资讯
  • 最新资讯
  • 应用排行榜
  • 游戏排行榜