VSFTP配置<一>------匿名用戶(hù)-創(chuàng)新互聯(lián)

簡(jiǎn)介:

創(chuàng)新互聯(lián)專(zhuān)注于從江網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供從江營(yíng)銷(xiāo)型網(wǎng)站建設(shè),從江網(wǎng)站制作、從江網(wǎng)頁(yè)設(shè)計(jì)、從江網(wǎng)站官網(wǎng)定制、微信小程序定制開(kāi)發(fā)服務(wù),打造從江網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供從江網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。

    安全性是編寫(xiě)VSFTP的初衷,除了這與生俱來(lái)的安全特性以外,高速與高穩(wěn)定性也是VSFTP的兩個(gè)重要特點(diǎn)。

    在速度方面,使用ASCII代碼的模式下載數(shù)據(jù)時(shí),VSFTP的速度是Wu-FTP的兩倍,如果Linux主機(jī)使用2.4.*的內(nèi)核,在千兆以太網(wǎng)上的下載速度可達(dá)86MB/S。

    在穩(wěn)定方面,VSFTP就更加的出色,VSFTP在單機(jī)(非集群)上支持4000個(gè)以上的并發(fā)用戶(hù)同時(shí)連接,根據(jù)Red Hat的Ftp服務(wù)器的數(shù)據(jù),VSFTP服務(wù)器可以支持15000個(gè)并發(fā)用戶(hù)

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

   OS:   CentOS 6.6
   vsftp:   vsftpd-2.2.2-12.el6_5.1.x86_64

一、vsftpd的安裝
   1、vsftp可以下載rpm安裝 也可以使用官方CD.iso 配置本地配置yum源進(jìn)行安裝
[root@1inux htdocs]# yum -y install vsftpd Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package vsftpd.x86_64 0:2.2.2-12.el6_5.1 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================  Package                        Arch                           Version                                  Repository                  Size ========================================================================================================================================= Installing:  vsftpd                         x86_64                         2.2.2-12.el6_5.1                         CD                         151 k Transaction Summary ========================================================================================================================================= Install       1 Package(s) Total download size: 151 k Installed size: 331 k Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction   Installing : vsftpd-2.2.2-12.el6_5.1.x86_64                                                                                        1/1    Verifying  : vsftpd-2.2.2-12.el6_5.1.x86_64                                                                                        1/1  Installed:   vsftpd.x86_64 0:2.2.2-12.el6_5.1                                                                                                        Complete! [root@1inux htdocs]#    2、查看vsftp安裝后生成的文件:
[root@1inux htdocs]# rpm -ql vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd        //用戶(hù)認(rèn)證配置文件 /etc/rc.d/init.d/vsftpd        //服務(wù)腳本 /etc/vsftpd        //配置文件目錄 /etc/vsftpd/vsftpd.conf        //配置文件 /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd_conf_migrate.sh /usr/sbin/vsftpd        //主程序 ..... /var/ftp    //匿名訪(fǎng)問(wèn)目錄 /var/ftp/pub

    3、安裝完成后啟動(dòng)vsftp

[root@1inux htdocs]# service vsftpd start Starting vsftpd for vsftpd:                                [  OK  ] [root@1inux htdocs]#=========================
匿名登錄FTP      匿名登錄方式:     (1)可以輸入用戶(hù)名ftp,密碼為空,然后登陸     (2) 用戶(hù)名、密碼都是anonymousftp> help   //CentOS ftp客戶(hù)端可以使用help命令獲取命令列表 !        debug        mdir        sendport    site $        dir        mget        put        size account        disconnect    mkdir        pwd        status append        exit        mls        quit        struct ascii        form        mode        quote        system bell        get        modtime        recv        sunique binary        glob        mput        reget        tenex bye        hash        newer        rstatus        tick case        help        nmap        rhelp        trace cd        idle        nlist        rename        type cdup        p_w_picpath        ntrans        reset        user chmod        lcd        open        restart        umask close        ls        prompt        rmdir        verbose cr        macdef        passive        runique        ? delete        mdelete        proxy        send ftp>主要命令介紹:
   ascii     以ascii碼傳輸數(shù)據(jù)
   binary   以二進(jìn)制方式傳輸數(shù)據(jù)
   chmod      修改權(quán)限
   cd       切換目錄
   lcd       本地目錄切換
   delete     刪除文件
   get       下載
   put       上傳
   mget      一次下載多個(gè)
   mput      一次上傳多個(gè)
   pwd       顯示當(dāng)前所在位置
   bye       退出

二、Vsftp匿名訪(fǎng)問(wèn)配置
注意:配置之前先對(duì)其配置文件進(jìn)行備份,以防止造成無(wú)法挽回的損失 # cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
1、禁止匿名用戶(hù)訪(fǎng)問(wèn):修改配置文件如下:

anonymous_enable=NO

[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 530 Login incorrect. Login failed.        //訪(fǎng)問(wèn)失敗 ftp>2、增加匿名用戶(hù)上傳權(quán)限
anon_upload_enable=YES   //啟用這一行

ftp> put fstab local: fstab remote: fstab 227 Entering Passive Mode (172,16,66,82,148,217). 553 Could not create file.         //還是提示無(wú)法創(chuàng)建, 這是因?yàn)関sftp服務(wù)是以ftp用戶(hù)啟動(dòng)的其對(duì)對(duì)/var/ftp目錄沒(méi)有寫(xiě)權(quán)限    解決方案:在/var/ftp/目錄下創(chuàng)建一個(gè)目錄更改其權(quán)限使ftp用戶(hù)對(duì)其有讀寫(xiě)權(quán)限:[root@1inux vsftpd]# mkdir /var/ftp/upload/ [root@1inux vsftpd]# cd /var/ftp/ [root@1inux ftp]# setfacl -m u:ftp:rwx upload/ [root@1inux ftp]# getfacl upload/ # file: upload/ # owner: root # group: root user::rwx user:ftp:rwx group::r-x mask::rwx other::r-x接下來(lái)我們?cè)偕蟼魑募囋?br />[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (172,16,66,82,201,178). 150 Here comes the directory listing. drwxr-xr-x    2 0        0            4096 Aug 04  2014 pub drwxrwxr-x    2 0        0            4096 May 01 20:43 upload 226 Directory send OK. ftp> cd upload 250 Directory successfully changed. ftp> lcd /etc Local directory now /etc ftp> put fstab local: fstab remote: fstab 227 Entering Passive Mode (172,16,66,82,47,38). 150 Ok to send data. 226 Transfer complete. 1127 bytes sent in 0.000133 secs (8473.68 Kbytes/sec) ftp> ls 227 Entering Passive Mode (172,16,66,82,233,197). 150 Here comes the directory listing. -rw-------    1 14       50           1127 May 01 20:52 fstab        //文件已經(jīng)存在 226 Directory send OK. ftp>3、創(chuàng)建目錄:
    默認(rèn)配置是禁止匿名用戶(hù)創(chuàng)建目錄的,可以通過(guò)修改配置文件更改:
anon_mkdir_write_enable=YES   //啟用這一行
然后保存,重新加載配置文件:[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd:                                      [  OK  ] Starting vsftpd for vsftpd:                                [  OK  ] [root@1inux vsftpd]#在客戶(hù)端匿名登錄創(chuàng)建目錄anontest
ftp> mkdir anontest 257 "/upload/anontest" created        //提示創(chuàng)建成功 ftp> ls 227 Entering Passive Mode (172,16,66,82,41,121). 150 Here comes the directory listing. drwx------    2 14       50           4096 May 01 21:02 anontest    //目錄已經(jīng)存在 -rw-------    1 14       50           1127 May 01 20:52 fstab 226 Directory send OK. ftp>4、刪除文件或目錄
   默認(rèn)配置中是無(wú)法刪除文件的,需要在配置文件中添加一行如下:
anon_other_write_enable=YES

匿名登錄:ftp> ls 227 Entering Passive Mode (172,16,66,82,233,251). 150 Here comes the directory listing. drwx------    2 14       50           4096 May 01 21:02 anontest -rw-------    1 14       50           1127 May 01 20:52 fstab 226 Directory send OK. ftp> delete fstab        //刪除文件 250 Delete operation successful. ftp> rmdir anontest        //刪除目錄 250 Remove directory operation successful. ftp> ls 227 Entering Passive Mode (172,16,66,82,237,22). 150 Here comes the directory listing. 226 Directory send OK. ftp>
三、本地用戶(hù)權(quán)限管理

1、使用系統(tǒng)用戶(hù)登陸: 【默認(rèn)情況下使用系統(tǒng)用戶(hù)登陸,登陸后可以在其家目錄下任意創(chuàng)建、上傳刪除文件或目錄】
local_enable=YES   //默認(rèn)此行啟用狀態(tài)
write_enable=YES   //寫(xiě)權(quán)限默認(rèn)開(kāi)啟
local_umask=022      //控制FTP登陸后的權(quán)限

   1.1、在vsftp上面添加一個(gè)用戶(hù):[root@1inux vsftpd]# useradd admin [root@1inux vsftpd]# passwd admin Changing password for user admin. New password:  BAD PASSWORD: it is WAY too short BAD PASSWORD: is a palindrome Retype new password:  passwd: all authentication tokens updated successfully. [root@1inux vsftpd]#   1.2、訪(fǎng)問(wèn)
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (172,16,66,82,236,21). 150 Here comes the directory listing. 226 Directory send OK. ftp> pwd         257 "/home/admin"    //使用系統(tǒng)用戶(hù)登陸默認(rèn)訪(fǎng)問(wèn)的是其家目錄 ftp> lcd /root    //切換本地目錄 ftp> pwd 257 "/etc"----------------------
2、禁止系統(tǒng)用戶(hù)訪(fǎng)問(wèn):
   2.1、修改配置文件:
   local_enable=NO
然后重新加載服務(wù)[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd:                                      [  OK  ] Starting vsftpd for vsftpd:                                [  OK  ] [root@1inux vsftpd]#   2.1、訪(fǎng)問(wèn):[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 530 This FTP server is anonymous only. Login failed.        //輸入用戶(hù)名后 直接提示失敗 ftp>
3、鎖定系統(tǒng)用戶(hù)至其家目錄
chroot_local_user=YES   //啟用此行
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): admin 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> lcd /etc Local directory now /etc ftp> ls 227 Entering Passive Mode (172,16,66,82,171,255). 150 Here comes the directory listing. drwxr-xr-x    2 501      501          4096 May 01 21:24 abc 226 Directory send OK.4、鎖定部分用戶(hù)至其家目錄,可以啟用以下行:
chroot_list_enable=YES   //啟用列表
chroot_list_file=/etc/vsftpd/chroot_list      //在此文件中的用戶(hù)都會(huì)被鎖定

   4.1、創(chuàng)建用戶(hù):[root@1inux vsftpd]# useradd centos [root@1inux vsftpd]# echo "1" | passwd --stdin centos [root@1inux vsftpd]# useradd fedora [root@1inux vsftpd]# echo "1" | passwd --stdin fedora [root@1inux vsftpd]#   4.2、創(chuàng)建用戶(hù)列表[root@1inux vsftpd]# vim chroot_list [root@1inux vsftpd]# cat chroot_list  centos   4.3、重新加載配置文件[root@1inux vsftpd]# service vsftpd reload Shutting down vsftpd:                                      [  OK  ] Starting vsftpd for vsftpd:                                [  OK  ]   4.4、登陸查看
1、以centos身份登陸 [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): centos 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp>  2、以fedora身份 登陸 [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): fedora 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/home/fedora"
四、其他簡(jiǎn)單配置說(shuō)明:
1、dirmessage_enable=YES      //目錄消息提示
在FTP要提示消息的目錄下新建文件:    # vim .message Hello, guest How are you?重載配置文件:# service vsftpd reload
[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 (vsFTPd 2.2.2) Name (172.16.66.82:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd upload 250-Hello, guest        //已經(jīng)提示剛才定義的消息 250-How are you? 250 Directory successfully changed. ftp>2、日志相關(guān)
    xferlog_enable=YES   //是否打開(kāi)傳輸日志,默認(rèn)開(kāi)啟
    xferlog_std_format=YES   //傳輸日志是否啟用標(biāo)準(zhǔn)格式
    xferlog_file=/var/log/xferlog   //日志路徑,【前面兩個(gè)都得啟用】

3、上傳屬主是否改變
    #chown_uploads=YES   //當(dāng)ftp上傳文件時(shí),是否更改其屬主
    #chown_username=whoever   //將屬主更為為whoever 即系統(tǒng)上的用戶(hù)名

4、超時(shí)相關(guān)
    #idle_session_timeout=600   //空閑會(huì)話(huà)超時(shí)時(shí)長(zhǎng),超過(guò)將自動(dòng)斷開(kāi)
    #data_connection_timeout=120   //數(shù)據(jù)連接超時(shí)時(shí)長(zhǎng)(即用戶(hù)上傳下載數(shù)據(jù)時(shí),數(shù)據(jù)連接斷開(kāi)后,ftp斷開(kāi)的超時(shí)時(shí)長(zhǎng))

5、上傳下載格式
    #ascii_upload_enable=YES   //其否強(qiáng)制使用ascill上傳
    #ascii_download_enable=YES   //其否強(qiáng)制使用ascill下載

注:當(dāng)上傳下載的是二進(jìn)制文件時(shí),強(qiáng)制使用ascill上傳下載會(huì)產(chǎn)生故障

6、ftp信息
#ftpd_banner=Welcome to blah FTP service. //用戶(hù)登陸時(shí)是否顯示歡迎信息,可自定義[root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service.        //登陸時(shí)顯示 Name (172.16.66.82:root):

7、vsftpd使用pam完成用戶(hù)認(rèn)證,其用到的pam配置文件

/etc/pam.d/vsftpd     //定義了用戶(hù)訪(fǎng)問(wèn)vsftpd時(shí)用哪個(gè)模塊對(duì)用戶(hù)做認(rèn)證
# cat /etc/pam.d/vsftpd  %PAM-1.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      password-auth account    include      password-auth session    required     pam_loginuid.so session    include      password-auth-------------------
auth   //做認(rèn)證用的
account   //檢查用戶(hù)賬號(hào)是否在有效期內(nèi)
session   //
_______/etc/pam.d/vsftpd  ______________ auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed-------------------------------------------------------------------------------------------

/etc/vsftpd/ftpusers 存放拒絕訪(fǎng)問(wèn)vsftp的用戶(hù)列表,用戶(hù)名一旦在此文件中出現(xiàn),其將會(huì)被禁止訪(fǎng)問(wèn)vsftp

eg: 服務(wù)器端: [root@1inux vsftpd]# echo "admin" >> ftpusers  [root@1inux vsftpd]# service vsftpd reload 客戶(hù)端: [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): admin 331 Please specify the password. Password: 530 Login incorrect. Login failed.    //登陸失敗 ftp>

8、控制用戶(hù)列表文件

    /etc/vsftpd/user_list
    userlist_enable=YES   //是否啟用控制用戶(hù)登陸的列表文件
    userlist_deny=YES|NO   //是否拒絕用戶(hù)列表中用戶(hù) 默認(rèn)是YES

eg1:
當(dāng)userlist_deny=YES時(shí),user_list文件就變成了黑名單,文件內(nèi)的用戶(hù)都不允許登陸

在user_list中添加centos用戶(hù)# echo "centos" >> /etc/vsftpd/user_list [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): centos 530 Permission denied.        //被拒絕訪(fǎng)問(wèn) Login failed. ftp>  ------eg2:
當(dāng)userlist_deny=NO時(shí),user_list文件就變成了白名單,只有user_list文件內(nèi)的用戶(hù)才允許登陸
[root@1inux vsftpd]# cat user_list  # vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody centos [root@1inux vsftpd]#  客戶(hù)端: [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): fedora 530 Permission denied.        //fedora 用戶(hù)直接被拒絕 Login failed. ftp> bye 221 Goodbye. [root@1inux ~]# ftp 172.16.66.82 Connected to 172.16.66.82 (172.16.66.82). 220 Welcome to blah FTP service. Name (172.16.66.82:root): centos 331 Please specify the password. Password: 230 Login successful.        //centos 用戶(hù)可以訪(fǎng)問(wèn) Remote system type is UNIX. Using binary mode to transfer files. ftp>
9、連接限制:
   max_clients:   大并發(fā)連接數(shù)
   max_per_ip:   每個(gè)IP可同時(shí)發(fā)起的大請(qǐng)求數(shù)

10、傳輸速率
   anon_max_rate:   匿名用戶(hù)的大傳輸速率,單位:“字節(jié)/秒”
   local_max_rate:   本地用戶(hù)的大傳輸速率

OK  虛擬用戶(hù)及系統(tǒng)用的的配置基本上就這么些......歡迎補(bǔ)充


更多配置參數(shù)請(qǐng)參考: man vsftpd.conf

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前標(biāo)題:VSFTP配置<一>------匿名用戶(hù)-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)網(wǎng)址:http://muchs.cn/article8/dchjip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站制作、電子商務(wù)響應(yīng)式網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)