iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >CentOS vsftpd怎么制作虚拟用户数据库文件
  • 857
分享到

CentOS vsftpd怎么制作虚拟用户数据库文件

2023-06-16 22:06:19 857人浏览 安东尼
摘要

本篇内容介绍了“Centos vsftpd怎么制作虚拟用户数据库文件”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!制作虚拟用户数据库文件先建

本篇内容介绍了“Centos vsftpd怎么制作虚拟用户数据库文件”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

制作虚拟用户数据库文件

先建立虚拟用户名单文件:[root@KcentOS5 ~]# touch /etc/vsftpd/virtusers建立了一个虚拟用户名单文件,这个文件就是来记录CentOS vsftpd虚拟用户的用户名和口令的数据文件,我这里给它命名为virtusers。为了避免文件的混乱,我把这个名单文件就放置在/etc/vsftpd/下。

编辑虚拟用户名单文件:

[root@KcentOS5 ~]# vi /etc/vsftpd/virtusers   kanecruise  123456  near  123456near  mello  123456mello

编辑这个虚拟用户名单文件,在其中加入用户的用户名和口令信息。格式很简单:“一行用户名,一行口令”。

生成虚拟用户数据文件:

[root@KcentOS5 ~]# db_load T t hash f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db这里我顺便把这个命令简单说明一下察看db4的db_load命令使用方法:

[root@KSRV2 vsftpd]# db_load  usage: db_load [nTV] [c name=value] [f file] [h home] [P passWord] [t btree | hash | recno | queue] db_file  usage: db_load r lsn | fileid [h home] [P password] db_file

解释在本篇中,db_load命令几个相关选项很参数

The T option allows nonBerkeley DB applications to easily load text files into databases.
If the database to be created is of type Btree or Hash, or the keyword keys is specified as set, the input must be paired
lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data
item. If the database to be created is of type Queue or Recno and the keywork keys is not set, the input must be lines of text, where each line is a new data item for the database.

选项T允许应用程序能够将文本文件转译载入进数据库。由于我们之后是将虚拟用户的信息以文件方式存储在文件里的,为了让CentOS vsftpd这个
应用程序能够通过文本来载入用户数据,必须要使用这个选项。

If the T option is specified, the underlying access method type must be specified using the t option. 如果指定了选项T,那么一定要追跟子选项tSpecify the underlying access method. If no t option is specified, the database will be loaded into a database of the same type as was dumped; for example, a Hash database will be created if a Hash database was dumped.

Btree and Hash databases may be converted from one to the other. Queue and Recno databases may be converted from one to the other. If the k option was specified on the call to db_dump then Queue and Recno databases may be converted to Btree or Hash, with the key being the integer record number.

子选项t,追加在在T选项后,用来指定转译载入的数据库类型。扩展介绍下,t可以指定的数据类型有Btree、Hash、Queue和Recon数据库。这里,接下来我们需要指定的是Hash型。

察看生成的虚拟用户数据文件

[root@KcentOS5 ~]# ll /etc/vsftpd/virtusers.db rwrr 1 root root 12288 Sep 16 03:51 /etc/vsftpd/virtusers.db
需要特别注意的是,以后再要添加虚拟用户的时候,只需要按照“一行用户名,一行口令”的格式将新用户名和口令添加进虚拟用户名单文件。但是光这样做还不够,不会生效的哦!还要再执行一遍“ db_load T t hash f 虚拟用户名单文件 虚拟用户数据库文件.db ”的命令使
其生效才可以!

设定PAM验证文件,并指定虚拟用户数据库文件进行读取

察看原来的Vsftp的PAM验证配置文件:[root@KcentOS5 ~]# cat /etc/pam.d/vsftpd

#%PAM1.0  session    optional     pam_keyinit.so    force revoke  auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed auth       required     pam_shells.so  auth       include      systemauth  account    include      systemauth  session    include      systemauth  session    required     pam_loginuid.so

在编辑前做好备份: [root@KcentOS5 ~]# cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.backup

编辑CentOS vsftpd的PAM验证配置文件[root@KcentOS5 ~]# vi /etc/pam.d/vsftpd

#%PAM1.0  auth    sufficient      /lib/security/pam_userdb.so     db=/etc/vsftpd/virtusers  account sufficient      /lib/security/pam_userdb.so     db=/etc/vsftpd/virtusers


以上两条是手动添加的,内容是对虚拟用户的安全和帐户权限进行验证。这里的auth是指对用户的用户名口令进行验证。这里的accout是指对用户的帐户有哪些权限哪些限制进行验证。

其后的sufficient表示充分条件,也就是说,一旦在这里通过了验证,那么也就不用经过下面剩下的验证步骤了。相反,如果没有通过的话,也不会被系统立即挡之门外,因为sufficient的失败不决定整个验证的失败,意味着用户还必须将经历剩下来的验证审核。

再后面的/lib/security/pam_userdb.so表示该条审核将调用pam_userdb.so这个库函数进行。***的db=/etc/vsftpd/virtusers则指定了验证库函数将到这个指定的数据库中调用数据进行验证。

#KC: The entries for VsftpdPAM are added above.  session    optional     pam_keyinit.so    force revoke  auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed auth       required     pam_shells.so  auth       include      systemauth  account    include      systemauth  session    include      systemauth  session    required     pam_loginuid.so

CentOS vsftpd虚拟用户的配置

规划好虚拟用户的主路径:[root@KcentOS5 ~]# mkdir /opt/vsftp/
2.建立测试用户的FTP用户目录:[root@KcentOS5 ~]# mkdir /opt/vsftp/kanecruise/ /opt/vsftp/mello/ /opt/vsftp/near/
3.建立虚拟用户配置文件模版:[root@KcentOS5 ~]# cp /etc/vsftpd/vsftpd.conf.backup /etc/vsftpd/vconf/vconf.tmp
4.定制虚拟用户模版配置文件:[root@KcentOS5 ~]# vi /etc/vsftpd/vconf/vconf.tmp

local_root=/opt/vsftp/virtuser指定虚拟用户的具体主路径。
anonymous_enable=NO设定不允许匿名用户访问。
write_enable=YES设定允许写操作。
local_umask=022设定上传文件权限掩码。
anon_upload_enable=NO设定不允许匿名用户上传。
anon_mkdir_write_enable=NO设定不允许匿名用户建立目录。
idle_session_timeout=600设定空闲连接超时时间。
data_connection_timeout=120设定单次连续传输***时间。
max_clients=10设定并发客户端访问个数。
max_per_ip=5设定单个客户端的***线程数,这个配置主要来照顾Flashget、迅雷等多线程下载软件。
local_max_rate=50000设定该用户的***传输速率,单位b/s。

这里将原CentOS vsftpd.conf配置文件经过简化后保存作为虚拟用户配置文件的模版。这里将并不需要指定太多的配置内容,主要的框架和限制交由 CentOS vsftpd的主配置文件CentOS vsftpd.conf来定义,即虚拟用户配置文件当中没有提到的配置项目将参考主配置文件中的设定。而在这里作为虚拟用户的配置文件模版只需要留一些和用户流量控制,访问方式控制的配置项目就可以了。这里的关键项是local_root这个配置,用来指定这个虚拟用户的FTP主路径。

更改虚拟用户的主目录的属主为虚拟宿主用户:[root@KcentOS5 ~]# chown R overlord.overlord /opt/vsftp/
6.检查权限:

[root@KcentOS5 ~]# ll /opt/vsftp/  total 24  drwxrxrx 2 overlord overlord 4096 Sep 16 05:14 kanecruise  drwxrxrx 2 overlord overlord 4096 Sep 16 05:00 mello  drwxrxrx 2 overlord overlord 4096 Sep 16 05:00 near

给测试用户定制:

从虚拟用户模版配置文件复制:[root@KcentOS5 ~]# cp /etc/vsftpd/vconf/vconf.tmp /etc/vsftpd/vconf/kanecruise
2.针对具体用户进行定制:[root@KcentOS5 ~]# vi /etc/vsftpd/vconf/kanecruise

local_root=/opt/vsftp/kanecruise  anonymous_enable=NO write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO idle_session_timeout=300 data_connection_timeout=90 max_clients=1 max_per_ip=1 local_max_rate=25000

CentOS vsftpd启动服务:

[root@KcentOS5 ~]# service vsftpd start  Starting vsftpd for vsftpd:                                [ OK ]

“CentOS vsftpd怎么制作虚拟用户数据库文件”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!

--结束END--

本文标题: CentOS vsftpd怎么制作虚拟用户数据库文件

本文链接: https://www.lsjlt.com/news/285955.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • CentOS vsftpd怎么制作虚拟用户数据库文件
    本篇内容介绍了“CentOS vsftpd怎么制作虚拟用户数据库文件”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!制作虚拟用户数据库文件先建...
    99+
    2023-06-16
  • 如何编辑CentOS vsftpd虚拟用户文件数据
    如何编辑CentOS vsftpd虚拟用户文件数据,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。先建立CentOS vsftpd虚拟用户名单文件:[root@K...
    99+
    2023-06-16
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作