004.FTP匿名使用者訪問
阿新 • • 發佈:2018-11-01
一 匿名使用者配置項
1 [[email protected]~]# vi /etc/vsftpd/vsftpd.conf 2 anonymous_enable #允許匿名使用者訪問 3 anon_upload_enable #允許匿名使用者上傳(建立)普通檔案 4 anon_mkdir_write_enable=YES #允許匿名使用者建立目錄 5 anon_umask #設定上傳的預設檔案許可權(預設為600)
二 修改匿名使用者主目錄許可權
注意:匿名使用者登陸後預設的主目錄為:/var/ftp/
2.1 檢視匿名使用者主目錄許可權
1 [[email protected]~]# ls -ld /var/ftp/ 2 drwxr-xr-x. 3 root root 36 Aug 28 23:33 /var/ftp/
提示:由於主目錄許可權中其他人(ftp使用者對此目錄所屬使用者和所屬組而言是其他人)不具有可讀,因此無法上傳檔案。
2.2 修改匿名使用者主目錄許可權
1 [[email protected] ~]# cd /var/ftp/ 2 [[email protected] ftp]# ls -l 3 total 0 4 drwxr-xr-x. 2 root root 6 Mar 31 23:12 pub 5 [[email protected]~]# chown ftp /var/ftp/pub #將匿名使用者主目錄下的pub目錄所屬人改為ftp,即讓匿名使用者可以在pub裡上傳 6 [[email protected] ftp]# chown ftp /var/ftp/pub/ 7 [[email protected] ftp]# ls -l 8 drwxr-xr-x. 2 ftp root 6 Mar 31 23:12 pub #ftp已是pub目錄的所屬人,具備可讀寫執行許可權
注意:
1:強烈不建議將主目錄中其他人許可權改為可讀寫且執行。
2:同時也不建議將/var/ftp/主目錄所屬人改為fpt(會報錯)。
三 重啟ftp服務
1 [[email protected] ~]# service restart vsftpd #Centos6系列 2 [[email protected] ~]# systemctl restart vsftpd #Centos7系列
四 測試登陸
1 E:\Temp>ftp 192.168.10.10 2 連線到 192.168.10.10。 3 220 (vsFTPd 3.0.2) 4 使用者(192.168.10.10:(none)): anonymous 5 331 Please specify the password. 6 密碼: 7 230 Login successful. 8 ftp> pwd 9 257 "/"
五 測試上傳及下載
5.1 下載
1 [[email protected] ~]# cd /var/ftp/ 2 [[email protected] ftp]# touch anon_down.txt 3 ftp>ls 4 200 PORT command successful. Consider using PASV. 5 150 Here comes the directory listing. 6 anonymous.txt 7 pub 8 226 Directory send OK. 9 ftp: 收到 23 位元組,用時 0.00秒 11.50千位元組/秒。 10 ftp> get anonymous.txt 11 200 PORT command successful. Consider using PASV. 12 150 Opening BINARY mode data connection for anonymous.txt (0 bytes). 13 226 Transfer complete.
5.2 上傳
1 E:\Temp>ftp 192.168.10.10 2 連線到 192.168.10.10。 3 220 (vsFTPd 3.0.2) 4 使用者(192.168.10.10:(none)): anonymous 5 331 Please specify the password. 6 密碼: 7 230 Login successful. 8 ftp> cd pub #進入具備許可權的目錄(此前配置許可權目錄,而非主目錄) 9 250 Directory successfully changed. 10 ftp> pwd 11 257 "/pub" 12 ftp> put anon_upload.txt 13 200 PORT command successful. Consider using PASV. 14 150 Ok to send data. 15 226 Transfer complete.
六 總結
- 1 預設上傳目錄建議為:/var/ftp/pub/。
- 2 如允許上傳,服務許可權和系統目錄許可權必須同時具備。
- 3 vsftp服務的偽使用者是ftp。