您可以通過點擊 右下角 的按鈕 來對文章內容作出評價, 也可以通過左下方的 關注按鈕 來關注我的博客的最新動態。
如果文章內容對您有幫助, 不要忘記點擊右下角的 推薦按鈕 來支持一下哦
如果您對文章內容有任何疑問, 可以通過評論或發郵件的方式聯系我: 501395377@qq.com / lzp501395377@gmail.com
如果需要轉載,請注明出處,謝謝!!
本篇隨筆將講解FTP服務的原理以及vsfptd這個最常用的FTP服務程序的安裝與配置...
一、FTP服務原理
FTP(File Transfer Protocol)是一個非常古老並且應用十分廣泛的文件傳輸協議,FTP協議是現今使用最為廣泛的網絡文件共享協議之一,我們現在也一直有在用着FTP協議來進行各種文件的傳輸,FTP為我們提供了一種可靠的方式在網絡上進行文件的共享
FTP是C/S架構的服務,擁有一個服務器端和一個客戶端,FTP底層通過TCP協議來作為傳輸協議,所以FTP協議是一種可靠的文件傳輸方式,FTP提供了兩個端口號,20和21號端口,20號是數據接口,提供數據之間的傳輸,21號是命令接口,提供命令之間的傳輸
FTP服務端與客戶端連接一般有兩種模式:主動模式(Active Mode)和被動模式(Passive Mode)
①主動模式的原理如下圖所示:
主動模式下,客戶端首先會向服務器端的21號端口發出一個連接命令,請求與服務器端建立連接,此時服務器端響應回去給客戶端,並要求客戶端發送一個用於傳送數據的端口,該端口號要 > 1023 ,此時服務器端的20號端口就會與該數據端口主動建立連接,客戶端與服務器端進行數據的傳送
②被動模式的原理如下圖所示:
與主動模式不同的是,在被動模式下,客戶端也是首先與服務器端的21端口建立連接,此時后服務器端會開啟一個 > 1023 號的數據傳送端口,並返回給客戶端,這個時候客戶端也會開啟一個 > 1023 的端口,然后客戶端會主動的去跟服務器端的數據傳輸端口建立連接,兩者之間來進行數據的傳送
所以說,主動模式與被動模式的區別就在於究竟是服務器端的20端口主動發起於客戶端建立連接,還是服務器端開放一個隨機端口,等待客戶端與其主動建立連接。在我們的生產環境中,通常還是使用的是被動連接的模式,因為我們的服務器端都有配置防火牆,而防火牆對於內網連接外網的端口一般是放行的,而外網來連接內網的端口則一般是有限制的,所以我們這時如果使用主動模式連接的話,端口可能被防火牆攔截,從而不能提供我們的FTP服務
二、vsfptd的安裝
在Linux下,我們應用最廣泛的FTP服務程序是 vsftpd (Very Secure FTP Daemon),從名字我們也可以看出,其提供了非常安全的FTP服務。vsftpd 是一個 UNIX 類操作系統上運行的服務器的名字,它可以運行在諸如 Linux, BSD, Solaris, HP-UX 以及 IRIX 上面。它支持很多其他的 FTP 服務器不支持的特征。例如:
①非常高的安全性需求 ②帶寬限制 ③創建虛擬用戶的可能性 ④高速 ...
可以說 vsftpd 給我們提供了一個快速的、穩定的且相當安全的FTP服務
在CentOS下默認沒有安裝 vsftpd 這個FTP程序,我們通過 yum install vsfptd 來進行安裝
[root@xiaoluo ~]# yum install -y vsftpd Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: ftp.nsysu.edu.tw * extras: ftp.nsysu.edu.tw * updates: ftp.twaren.net Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package vsftpd.x86_64 0:2.2.2-11.el6_4.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: vsftpd x86_64 2.2.2-11.el6_4.1 updates 151 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 151 k Installed size: 331 k Downloading Packages: vsftpd-2.2.2-11.el6_4.1.x86_64.rpm | 151 kB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1 Verifying : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1 Installed: vsftpd.x86_64 0:2.2.2-11.el6_4.1 Complete!
這樣我們就安裝好了我們的 vsftpd 服務程序了,在安裝好后我們可以來看一下 vsftpd 這個程序的一些配置文件,其所有的配置文件都保存在了 /etc/vsftpd/ 這個目錄下
[root@xiaoluo ~]# cd /etc/vsftpd/ [root@xiaoluo vsftpd]# ls -l total 20 -rw-------. 1 root root 125 Mar 1 18:16 ftpusers -rw-------. 1 root root 361 Mar 1 18:16 user_list -rw-------. 1 root root 4599 Mar 1 18:16 vsftpd.conf -rwxr--r--. 1 root root 338 Mar 1 18:16 vsftpd_conf_migrate.sh
里面一共有四個配置文件,vsftpd.conf 是我們的主配置文件,ftpusers是我們的黑名單用戶配置文件,通常我們的系統用戶還有根用戶都是放在這個配置文件里面的,因為這些用戶的權限很大,如果使用ftp服務可能造成一些問題,user_list是我們的用戶列表文件,我們可以通過在主配置文件里設置該用戶是黑名單用戶還是白名單擁有,最后一個是我們的ftp服務遷移腳本
我們的 vsftpd 程序安裝好后,我們可以看到在 /var 目錄下有個 ftp 文件夾,這個文件夾就是我們的ftp共享文件夾
[root@xiaoluo vsftpd]# cd /var/ftp/ [root@xiaoluo ftp]# ls pub
三、FTP用戶以及如何進行文件共享
vsftpd是通過使用用戶來作為管理單位的,想要訪問某個ftp的共享文件,必須要以某一特定的用戶身份登陸,我們可以配置一下幾種類型的用戶:
①正常用戶(系統用戶)
正常用戶就是我們操作系統的系統用戶,一般我們安裝的各種服務都能通過系統用戶登錄來使用其所提供的服務
首先我們啟動我們的 vsftpd 這個服務,這里我們先通過 CentOS提供的一個圖形界面工具來使用我們現在的系統用戶登陸我們的 ftp
[root@xiaoluo ftp]# service vsftpd start Starting vsftpd for vsftpd: [ OK ]
輸入我們的當前系統用戶名及密碼就能登陸上去了,我們使用系統用戶登陸上去后,其默認打開的文件夾是我們的用戶的家目錄,只要是該用戶有訪問權限的文件及文件夾,該用戶都能進行訪問
②匿名用戶 (anonymous)
我們所有的FTP服務都支持的一種用戶登錄方式,我們可以不輸入任何信息就能登陸進來
我們看到,我們在沒有輸入任何信息也能夠登陸上我們的ftp,這就是以匿名用戶登錄的方式。
在默認情況下,在vsftpd安裝的時候會創建一個 ftp 系統用戶,這個用戶就是用來進行匿名登陸的用戶,ftp匿名用戶默認登陸到的目錄是 /var/ftp/ 目錄,沒有任何訪問限制權限的文件都能提供給匿名用戶進行共享
[root@xiaoluo ftp]# cat /etc/passwd | grep ftp ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
那么我們的FTP為什么可以以匿名用戶來進行登陸呢?其主要就是因為 vsftpd.conf 這個配置文件所配置的
[root@xiaoluo ftp]# cat /etc/vsftpd/vsftpd.conf # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=YES // 允許匿名用戶進行登陸 # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # The target log file can be vsftpd_log_file or xferlog_file. # This depends on setting xferlog_std_format parameter xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # The name of log file when xferlog_enable=YES and xferlog_std_format=YES # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log #xferlog_file=/var/log/xferlog # # Switches between logging into vsftpd_log_file and xferlog_file files. # NO writes to vsftpd_log_file, YES to xferlog_file xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). #chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES
我們看到,配置文件里的 anonymous_enable=YES 就是允許我們的匿名用戶登錄,如果將其設置成NO,這樣匿名用戶就不能登陸上了
③虛擬用戶(ftp-only)
這些用戶就是專門創建只為使用ftp的用戶,一般用的較少
我們登陸FTP,不僅可以使用CentOS提供的GUI界面,還可以使用我們的命令行下的工具進行登陸,這里我們使用的是 lftp,同樣我們也需要先對其進行安裝
[root@xiaoluo ~]# yum install -y lftp Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: ftp.nsysu.edu.tw * extras: ftp.nsysu.edu.tw * updates: ftp.twaren.net Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package lftp.x86_64 0:4.0.9-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: lftp x86_64 4.0.9-1.el6 base 753 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 753 k Installed size: 2.5 M Downloading Packages: lftp-4.0.9-1.el6.x86_64.rpm | 753 kB 00:10 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : lftp-4.0.9-1.el6.x86_64 1/1 Verifying : lftp-4.0.9-1.el6.x86_64 1/1 Installed: lftp.x86_64 0:4.0.9-1.el6 Complete!
這樣我們就可以使用 lftp 來登陸我們的ftp了
①直接使用 lftp 127.0.0.1 進行登陸
[root@xiaoluo ~]# lftp 127.0.0.1 lftp 127.0.0.1:~> pwd ftp://127.0.0.1 lftp 127.0.0.1:~> ls drwxr-xr-x 2 0 0 4096 Mar 01 10:16 pub
這種登陸是以匿名用戶登錄上ftp,我們可以看到登陸進去后的目錄是 /var/pub 這個共享目錄
②使用 lftp -u xiaoluo 127.0.0.1 進行登陸
[root@xiaoluo ~]# lftp -u xiaoluo 127.0.0.1 Password: lftp xiaoluo@127.0.0.1:~> pwd ftp://xiaoluo@127.0.0.1 lftp xiaoluo@127.0.0.1:~> ls drwxr-xr-x 2 500 500 4096 May 26 05:22 Desktop drwxr-xr-x 3 500 500 4096 May 19 16:10 Documents drwxr-xr-x 2 500 500 4096 May 13 17:36 Downloads drwxr-xr-x 2 500 500 4096 May 13 17:36 Music drwxr-xr-x 2 500 500 4096 May 13 17:36 Pictures drwxr-xr-x 2 500 500 4096 May 13 17:36 Public drwxr-xr-x 2 500 500 4096 May 13 17:36 Templates drwxr-xr-x 2 500 500 4096 May 13 17:36 Videos
我們也可以通過 -u 指定我們以系統用戶的方式登陸ftp,系統用戶登錄上以后,默認登陸的文件夾就是我們用戶的根目錄
四、用戶通過ftp進行文件上傳、下載操作
①正常用戶的上傳、下載操作
我們通過lftp命令還可以進行文件的上傳、下載操作,分別使用 put 和 get 命令
例如我現在在 xiaoluo 這個用戶的家目錄下創建一個 xiaoluo.txt 文件,然后我們通過 get 命令將其從ftp上下載下來
[xiaoluo@xiaoluo ~]$ touch xiaoluo.txt [xiaoluo@xiaoluo ~]$ ls Desktop Downloads Pictures Templates xiaoluo.txt Documents Music Public Videos [xiaoluo@xiaoluo ~]$ su - Password: [root@xiaoluo ~]# lftp -u xiaoluo 127.0.0.1 Password: lftp xiaoluo@127.0.0.1:~> ls drwxr-xr-x 2 500 500 4096 May 26 05:22 Desktop drwxr-xr-x 3 500 500 4096 May 19 16:10 Documents drwxr-xr-x 2 500 500 4096 May 13 17:36 Downloads drwxr-xr-x 2 500 500 4096 May 13 17:36 Music drwxr-xr-x 2 500 500 4096 May 13 17:36 Pictures drwxr-xr-x 2 500 500 4096 May 13 17:36 Public drwxr-xr-x 2 500 500 4096 May 13 17:36 Templates drwxr-xr-x 2 500 500 4096 May 13 17:36 Videos -rw-rw-r-- 1 500 500 0 Jun 08 16:20 xiaoluo.txt lftp xiaoluo@127.0.0.1:~> get xiaoluo.txt lftp xiaoluo@127.0.0.1:~> exit [root@xiaoluo ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog xiaoluo.txt
我們看到,剛才我們通過登陸xiaoluo這個用戶,然后在其家目錄下創建了一個 xiaoluo.txt 的文件,然后我們切換到了 root 目錄下,首先登陸我們的 lftp ,然后通過 get 命令將該文件下載下來,這時我們就可以發現root用戶的家目錄下就有了剛才下載下來的 xiaoluo.txt 文件的
【注意:】我當前root用戶是在哪個目錄下通過 lftp 登陸的,在下載文件時就會下載到該目錄下
同時我們也可以使用 put 命令來上傳文件到ftp上
[root@xiaoluo ~]# touch root.txt [root@xiaoluo ~]# ls anaconda-ks.cfg install.log root.txt Desktop install.log.syslog xiaoluo.txt [root@xiaoluo ~]# lftp -u xiaoluo 127.0.0.1 Password: lftp xiaoluo@127.0.0.1:~> put root.txt lftp xiaoluo@127.0.0.1:~> ls drwxr-xr-x 2 500 500 4096 May 26 05:22 Desktop drwxr-xr-x 3 500 500 4096 May 19 16:10 Documents drwxr-xr-x 2 500 500 4096 May 13 17:36 Downloads drwxr-xr-x 2 500 500 4096 May 13 17:36 Music drwxr-xr-x 2 500 500 4096 May 13 17:36 Pictures drwxr-xr-x 2 500 500 4096 May 13 17:36 Public drwxr-xr-x 2 500 500 4096 May 13 17:36 Templates drwxr-xr-x 2 500 500 4096 May 13 17:36 Videos -rw-r--r-- 1 500 500 0 Jun 08 16:26 root.txt -rw-rw-r-- 1 500 500 0 Jun 08 16:20 xiaoluo.txt lftp xiaoluo@127.0.0.1:~> exit [root@xiaoluo ~]# cd /home/xiaoluo/ [root@xiaoluo xiaoluo]# ls Desktop Downloads Pictures root.txt Videos Documents Music Public Templates xiaoluo.txt
我在root家目錄下創建了 root.txt 這個文件,然后通過 xiaoluo 這個用戶上傳到了 ftp 上,這時我們切換到xiaoluo的家目錄下,發現該文件已經上傳上去了
【注意:】我們在使用ftp進行文件上傳、下載操作時,要確保該用戶對目錄具有讀寫的權限!!!
②匿名用戶上傳、下載操作
我們匿名用戶登陸ftp以后默認對共享文件夾只有讀的權限,即只能從共享目錄里進行文件的下載操作
[root@xiaoluo ~]# cd /var/ftp/pub/ [root@xiaoluo pub]# touch xiaoluo.txt [root@xiaoluo pub]# ls xiaoluo.txt [root@xiaoluo pub]# cd [root@xiaoluo ~]# lftp 127.0.0.1 lftp 127.0.0.1:~> cd pub/ lftp 127.0.0.1:/pub> ls -rw-r--r-- 1 0 0 0 Jun 08 16:39 xiaoluo.txt lftp 127.0.0.1:/pub> get xiaoluo.txt lftp 127.0.0.1:/pub> exit [root@xiaoluo ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog xiaoluo.txt
那么我們要如何通過設置來實現文件的上傳操作呢?
(1) 修改vsftpd主配置文件開啟匿名用戶上傳的功能:
anonymous_enable=YES --開啟匿名用戶訪問(默認)
anon_upload_enable=YES --打開匿名用戶文件上傳功能
anon_mkdir_write_enable=YES --打開匿名用戶創建文件夾功能
[root@xiaoluo ~]# vim /etc/vsftpd/vsftpd.conf # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=YES # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # The target log file can be vsftpd_log_file or xferlog_file. # This depends on setting xferlog_std_format parameter xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # The name of log file when xferlog_enable=YES and xferlog_std_format=YES # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log #xferlog_file=/var/log/xferlog # # Switches between logging into vsftpd_log_file and xferlog_file files. # NO writes to vsftpd_log_file, YES to xferlog_file xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). #chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES
(2) 賦予匿名用戶上傳使用的文件夾以寫的權限
[root@xiaoluo ~]# chmod 2777 /var/ftp/pub/ [root@xiaoluo ~]# ls -ld /var/ftp/pub/ drwxrwsrwx. 2 root root 4096 Jun 9 00:42 /var/ftp/pub/
此時我們重新啟動我們 vsftpd 服務,就可以使用匿名用戶來進行文件上傳的操作了
[root@xiaoluo ~]# service vsftpd restart Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ] [root@xiaoluo ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog [root@xiaoluo ~]# touch xiaoluo.txt [root@xiaoluo ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog xiaoluo.txt [root@xiaoluo ~]# lftp 127.0.0.1 lftp 127.0.0.1:~> cd pub/ lftp 127.0.0.1:/pub> ls lftp 127.0.0.1:/pub> put xiaoluo.txt lftp 127.0.0.1:/pub> exit [root@xiaoluo ~]# cd /var/ftp/pub/ [root@xiaoluo pub]# ls xiaoluo.txt
我們看到,我們在 root 家目錄下創建的 xiaoluo.txt 文件已經通過 匿名用戶登錄上傳上去了
【注意:】我們不能將匿名用戶的家目錄的權限設置為777權限,也就是 /var/ftp 這個目錄,而只能設置其子目錄的權限為 777,因為vsftp認為這樣是很不安全的,如果這樣設置了,vsftpd將禁止訪問匿名用戶的家目錄
至此,本篇隨筆的編寫就告一段落了,本篇隨筆主要講解了FTP服務的原理以及vsftpd這個FTP服務程序的安裝、配置使用,有關 vsftpd.conf 這個主配置文件的更多高級配置將在以后的隨筆中進行詳細講解。。。。。。好了,收筆睡覺!!!!