linux-第十二课时笔记-[FTP服务器搭建]-[虚拟用户FTP]-[03]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux-第十二课时笔记-[FTP服务器搭建]-[虚拟用户FTP]-[03]相关的知识,希望对你有一定的参考价值。

FTP虚拟用户服务器搭建:

 

创捷一个账号列表:

    [[email protected] vsftpd]# echo -e "msl23\\n123\\nbenet\\n123" >> vusers.list

    [[email protected] vsftpd]# cat vusers.list

    msl23

    123

    benet

    123

    [[email protected] vsftpd]#

 

使用db_load把别表变为数据库:

    [[email protected] vsftpd]# db_load -T -t hash -f vusers.list vusers.db

      -T:其他程序使用该数据库的话必须用-T

      -t:算法 \\ 加密算法 这里采用的是 hash 哈希

      -f:密码文件

    [[email protected]x vsftpd]# file vusers.db

    vusers.db: Berkeley DB (Hash, version 9, native byte-order)

 

设置账号密码文件增强安全性:

    [[email protected] vsftpd]# ll vusers.*

    -rw------- 1 root root 12288 Aug 22 06:11 vusers.db

    -rw------- 1 root root    20 Aug 22 06:07 vusers.list

 

设置PAM认证:

    [[email protected] vsftpd]# vim /etc/pam.d/vsftpd.vu

    auth    required   pam_userdb.so db=/etc/vsftpd/vusers

    account required   pam_userdb.so db=/etc/vsftpd/vusers

 

创建账号一个virtual账号使虚拟账号映射到该用户:

    [[email protected] vsftpd]# useradd -d /var/ftproot/ -s /sbin/nologin virtual

    [[email protected] vsftpd]# id virtual

    uid=503(virtual) gid=503(virtual) groups=503(virtual)

    [[email protected] vsftpd]#

 

创建虚拟账号配置文件以账号名命名:

    [[email protected] vsftpd]# mkdir ./vusers.dir

    [[email protected] vsftpd]# cd ./vusers.dir

    [[email protected] vusers.dir]# touch msl23

    [[email protected] vusers.dir]# touch benet

    [[email protected] vusers.dir]# ls

    benet  msl23

    [[email protected] vusers.dir]#

 

编写配置文件:

  用户msl23:

    [[email protected] vusers.dir]# vim msl23

    anon_upload_enable=YES         #允许上传

    anon_mkdir_write_enable=YES    #运行创建目录

    anon_other_write_enable=YES    #开启其他权限

    anon_max_rate=0         #最大速度  0为不限速

    local_root=/var/msl23   #设置根目录

 

  用户benet:

    [[email protected] vusers.dir]# vim benet

    anon_upload_enable=YES

    anon_max_rate=0

    local_root=/var/benet

 

配置vsftpd配置文件关联账户配置文件:

    [[email protected] vsftpd]# vim vsftpd.conf

     12 anonymous_enable=NO    #关闭匿名用户

    119 pam_service_name=vsftpd.vu    #pam认真地址

    120 guest_enabled=YES #激活来宾用户

    121 guest_username=virtual #设置来宾用户名

    122 userlist_enable=YES

    123 tcp_wrappers=YES

    124 user_config_dir=/etc/vsftpd/vusers.dir/  #关联账号配置文件

 

创建虚拟用户的ftp目录并设置属主为virtual:

    [[email protected] vsftpd]# mkdir /var/msl23

    [[email protected] vsftpd]# mkdir /var/benet

    [[email protected] vsftpd]# chown virtual /var/benet

    [[email protected] vsftpd]# chown virtual /var/msl23

    [[email protected] vsftpd]# ll -d /var/msl23 /var/benet

    drwxr-xr-x 2 virtual root 4096 Aug 22 06:37 /var/benet

    drwxr-xr-x 2 virtual root 4096 Aug 22 06:36 /var/msl23

 

启动服务:

    [[email protected] vsftpd]# /etc/init.d/vsftpd reload

    Shutting down vsftpd:           [  OK  ]

    Starting vsftpd for vsftpd:    [  OK  ]

 

验证:

Msl23:

   技术分享

 

Benet:

   技术分享

 

 

 

 

 

 

以上是关于linux-第十二课时笔记-[FTP服务器搭建]-[虚拟用户FTP]-[03]的主要内容,如果未能解决你的问题,请参考以下文章

学习Linux的第十四课时

第十二课时之标准库浏览II

第十二章   Linux   DNS域名解析

第十二章   Linux   DNS域名解析

第十二章 FTP 服务器的安装与配置

第十二课时:时序分析中的基本概念和术语