1. 程式人生 > >linux-第十二課時筆記-[FTP服務器搭建]-[虛擬用戶FTP]-[03]

linux-第十二課時筆記-[FTP服務器搭建]-[虛擬用戶FTP]-[03]

vim 服務 name -s 2-2 span 筆記 驗證 acc

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] 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]