欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          使用vsftpd服務(wù)傳輸文件(匿名用戶(hù)認(rèn)證、本地用戶(hù)認(rèn)證、虛擬用戶(hù)認(rèn)證)

          vsftpd是一款運(yùn)行在Linux操作系統(tǒng)上的FTP服務(wù)程序,不僅完全開(kāi)源而且免費(fèi),此外,還具有很高的安全性、傳輸速度,以及支持虛擬用戶(hù)驗(yàn)證等其他FTP服務(wù)程序不具備的特點(diǎn)。

          vsftd作為更加安全的文件傳輸?shù)姆?wù)程序,允許用戶(hù)以三種認(rèn)證模式登錄到FTP服務(wù)器上。

          • 匿名開(kāi)放模式: 是一種最不安全的認(rèn)證模式,任何人都可以無(wú)需密碼驗(yàn)證而直接登錄到FTP服務(wù)器。
          • 本地用戶(hù)模式
            是通過(guò)Linux系統(tǒng)的本地賬戶(hù)密碼信息進(jìn)行認(rèn)證,相較于匿名開(kāi)放模式更安全。但是如果被×××破解了賬戶(hù)的信息,就可以暢通無(wú)阻登錄FTP服務(wù)器,從而完全控制整臺(tái)服務(wù)器。
          • 虛擬用戶(hù)模式
            是這三種模式中最安全的一種認(rèn)證模式,它需要為FTP服務(wù)單獨(dú)建立用戶(hù)數(shù)據(jù)庫(kù)文件,虛擬出用來(lái)進(jìn)行口令驗(yàn)證的賬戶(hù)信息,而這些賬戶(hù)信息在服務(wù)器系統(tǒng)中實(shí)際上是不存在的,僅供FTP服務(wù)程序進(jìn)行認(rèn)證使用。

            實(shí)驗(yàn)環(huán)境

            FTP服務(wù)器配置完yum倉(cāng)庫(kù)后,安裝vsftpd服務(wù)程序 

          匿名開(kāi)放模式

          vsftpd服務(wù)程序默認(rèn)開(kāi)啟了匿名開(kāi)放模式,需要開(kāi)啟匿名用戶(hù)的上傳、下載權(quán)限,以及讓匿名用戶(hù)創(chuàng)建、刪除、更名文件的權(quán)限。真實(shí)環(huán)境不建議這樣配置。FTP服務(wù)器匿名用戶(hù)對(duì)應(yīng)的系統(tǒng)用戶(hù)是ftp。

          anonymous_enable=YES / /允許匿名訪(fǎng)問(wèn)
          anon_upload_enable=YES //允許匿名用戶(hù)上傳文件
          anon_mkdir_write_enable=YES //允許匿名用戶(hù)創(chuàng)建目錄
          anon_other_write_enable=YES//允許匿名用戶(hù)修改或刪除目錄
          anon_umask=022 //設(shè)置匿名用戶(hù)上傳數(shù)據(jù)的權(quán)限掩碼

            service iptables stop                 setenforce 

          在客戶(hù)端執(zhí)行ftp命令連接到ftp服務(wù)器,默認(rèn)訪(fǎng)問(wèn)FTP根目錄/var/ftp?;诎踩钥紤],F(xiàn)TP根目錄的權(quán)限不允許匿名用戶(hù)或其他用戶(hù)有寫(xiě)入權(quán)限(否則訪(fǎng)問(wèn)時(shí)會(huì)報(bào)500錯(cuò)誤)

          /var/ftp目錄下默認(rèn)創(chuàng)建了一個(gè)子文件夾pub,可以在匿名訪(fǎng)問(wèn)時(shí)供上傳文件使用,那就要確保匿名用戶(hù)ftp對(duì)該目錄擁有寫(xiě)入權(quán)限。

            [root@RedHat6  drwxr-xr-x. 

          客戶(hù)端測(cè)試:

            yum install ftp -y                           
            Connected to ).  )  Name (  Please specify the password.  Password:                                                  Login successful.  Remote system type  UNIX.  Using binary mode to transfer files.  ftp> ls                                                        ).  150 Here comes the directory listing.  -rw-r--r--    1 0        0               7 Mar 26 02:42 ftp.txt  drwxr-xr-x    2 14       0            4096 Feb 12  2013 pub  226 Directory send OK.  ftp>   local: ftp.txt remote: ftp.txt  227 Entering Passive ).  150 Opening BINARY mode data connection ).  226 Transfer complete.  7 bytes received )  ftp> cd pub                                           250 Directory successfully changed.  ftp> put 123.txt                                     local: 123.txt remote: 123.txt  227 Entering Passive ).  150 Ok to send data.  226 Transfer complete.  7 bytes sent )  ftp> ls                                             227 Entering Passive ).  150 Here comes the directory listing.  -rw-------    1 14       50              7 Mar 26 02:44 123.txt  226 Directory send OK.  ftp> mkdir data                                    257 "/pub/data" created  ftp> quit                                     221 Goodbye.

          本地用戶(hù)模式

          之前用的是匿名開(kāi)放模式,現(xiàn)在關(guān)了,然后開(kāi)啟本地用戶(hù)模式。創(chuàng)建一個(gè)本地用戶(hù)zhangsan進(jìn)行測(cè)試。

          anonymous_enable=NO //禁止匿名訪(fǎng)問(wèn)
          local_enable=YES //允許本地用戶(hù)模式
          write_enable=YES //設(shè)置可寫(xiě)權(quán)限
          local_umask=022 //設(shè)置本地用戶(hù)模式創(chuàng)建文件的umask值

          在客戶(hù)端執(zhí)行ftp命令連接到ftp服務(wù)器,默認(rèn)訪(fǎng)問(wèn)的是該用戶(hù)的家目錄,而且該目錄的默認(rèn)所有者、所屬組都是該用戶(hù)自己。

          客戶(hù)端測(cè)試:

          [root@RedHat6-1 ~]# ftp 192.168.10.50  Connected to 192.168.10.50 (192.168.10.50).  220 (vsFTPd 2.2.2)  Name (192.168.10.50:root): zhangsan                         //zhangsan用戶(hù)登入  331 Please specify the password.  Password:                                                                    //輸入用戶(hù)的密碼  230 Login successful.  Remote system type is UNIX.  Using binary mode to transfer files.    257 "/files" created    227 Entering Passive Mode (192,168,10,50,117,63).  150 Here comes the directory listing.  drwxr-xr-x    2 500      500          4096 Mar 26 03:03 files  226 Directory send OK.    350 Ready for RNTO.  250 Rename successful.    227 Entering Passive Mode (192,168,10,50,147,228).  150 Here comes the directory listing.  drwxr-xr-x    2 500      500          4096 Mar 26 03:03 database  226 Directory send OK.    250 Remove directory operation successful.    227 Entering Passive Mode (192,168,10,50,123,117).  150 Here comes the directory listing.  226 Directory send OK.    221 Goodbye.

          需要注意的是7版本需要在配置文件添加“allow_writeable_chroot=YES”參數(shù)才允許本地用戶(hù)登錄。 //允許對(duì)禁錮的FTP根目錄執(zhí)行寫(xiě)入操作,而且不拒絕用戶(hù)的登錄請(qǐng)求

          1.禁錮宿主目錄

          若還希望將所有的宿主目錄禁錮在其宿主目錄中,可以添加chroot_local_user配置項(xiàng),否則用戶(hù)將能夠任意切換到服務(wù)器的/var/、/etc/、/boot/等宿主目錄以外的文件夾,這樣一來(lái)便存在安全隱患。

          chroot_local_user=YES //禁錮宿主目錄

          客戶(hù)端測(cè)試:

            550 Failed to change directory.    550 Failed to change directory.    221 Goodbye.
          2.黑白名單

          然而當(dāng)使用root管理員登錄后,系統(tǒng)提示如下錯(cuò)誤信息:

            Connected to ).  )  Name (以root用戶(hù)登錄   Permission denied.  Login failed.

          這是因?yàn)関sftpd服務(wù)程序所在的目錄中默認(rèn)存放著一個(gè)名為“用戶(hù)名單”的文件user_list,默認(rèn)userlist_deny=YES,所以這個(gè)名單上出現(xiàn)的名字將不允許登陸到ftp服務(wù)器,也就是黑名單。

          [root@RedHat6-2 ~]# cd /etc/vsftpd/  [root@RedHat6-2 vsftpd]# ls  ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh  [root@RedHat6-2 vsftpd]# vim user_list               //查看user_list文件    #       root  bin  daemon  adm  lp  sync            //這些用戶(hù)默認(rèn)不允許登錄ftp服務(wù)器  shutdown  halt  mail  news  uucp  operator  games  nobody
          虛擬用戶(hù)模式
          第1步:

          創(chuàng)建用于進(jìn)行FTP認(rèn)證的用戶(hù)數(shù)據(jù)庫(kù)文件,其中奇數(shù)行為賬戶(hù)名,偶數(shù)行為密碼。

            [root@RedHat6    rose  abc123  jack  abc123
            [root@RedHat6  vuser.db: Berkeley DB (Hash, version , native byte-order)  [root@RedHat6  [root@RedHat6
          第2步:

          創(chuàng)建vsftpd服務(wù)程序用于存儲(chǔ)文件的根目錄以及虛擬用戶(hù)映射的系統(tǒng)本地用戶(hù)。FTP服務(wù)用語(yǔ)存儲(chǔ)文件的根目錄指的是,當(dāng)虛擬用戶(hù)登錄后訪(fǎng)問(wèn)的默認(rèn)位置。

          第3步:

          建立用于支持虛擬用戶(hù)的PAM文件vfstpd.vu,其中“db=”參數(shù)是使用db_load命令生成的賬戶(hù)密碼數(shù)據(jù)庫(kù)文件的路徑。

              auth required pam_userdb.so db=/etc/vsftpd/vuser   account required pam_userdb.so db=/etc/vsftpd/vuser 
          第4步:

          在vsftpd服務(wù)程序的主配置文件中通過(guò)pam_service_name參數(shù)將pam認(rèn)證文件的名稱(chēng)修改為vsftpd.vu,再添加 guest_enable、guest_username參數(shù)。

          anonymous_enable=NO //禁止匿名訪(fǎng)問(wèn)
          guest_enable=YES //開(kāi)啟虛擬用戶(hù)模式
          guest_username=virtual //指定虛擬用戶(hù)賬戶(hù)
          pam_service_name=vsftpd.vu //指定PAM文件

          第5步:

          為虛擬用戶(hù)設(shè)置不同的權(quán)限。先創(chuàng)建虛擬用戶(hù)不同權(quán)限的配置文件的存放路徑,在這個(gè)路徑下再分別創(chuàng)建rose和jack命名的文件。

          第6步:

          再次修改vsftpd主配置文件,通過(guò)添加user_config_dir參數(shù)定義這兩個(gè)虛擬用戶(hù)不同權(quán)限的配置文件所存放的路徑,重啟vsftpd服務(wù)。

          user_config_dir=/etc/vsftpd/vu_dir //單獨(dú)用戶(hù)配置文件

          客戶(hù)端測(cè)試:

            Connected to ).  )  Name (  Please specify the password.  Password:                        Login successful.  Remote system type  UNIX.  Using binary mode to transfer files.  ftp> put anaconda-ks.cfg                                 local: anaconda-ks.cfg remote: anaconda-ks.cfg  ).  150 Ok to send data.  226 Transfer complete.  1498 bytes sent )  ftp> quit  221 Goodbye.
            [root@RedHat6  總用量   -rw-r--r--. 

          如何在Ubuntu 18.04 LTS上安裝帶有TLS的VsFTPD服務(wù)器  http://www.haoyitu.cn/Linux/2018-10/154930.htm

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)