基於ECS搭建FTP服務

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"基於ECS搭建FTP服務","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1. 資源創建","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這裏直接使用阿里雲提供的免費服務器,單擊【免費開通】 ","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/4d/4d08f32afaf6892ba39cc2c873312e72.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以看到其爲我們提供了用戶名 & 密碼 & IP地址,接下來只需要登錄遠程服務器即可","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2. 遠程連接ECS服務器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這裏我使用 Xshell軟件進行連接(Xshell 用起來還是很方便的,大家可以自行下載一下,或者使用別的軟件連接也可以)","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"登錄成功後如下: ","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/1e/1eaa0b5dc94635097932445a5509f735.pngr","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3. 安裝 vsftpd","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"vsftpd(very secure FTP daemon):FTP服務器","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"匿名訪問:任何用戶都可以訪問搭建的FTP服務","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本地用戶模式:只支持添加的本地用戶訪問搭建的FTP服務","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"安裝命令 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"yun install -y vsftpd","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"-y 表示安裝過程中提示選擇全部爲 “yes”","attrs":{}}]}],"attrs":{}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"顯示如下則安裝成功 ","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/50/50823470b9c73270ff28ae0306d26649.pngr","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"設置FTP服務開機自啓動","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令: ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"systemctl enable vsftpd.service","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"顯示如下則設置成功:","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e9/e9e71d2226950200342676e27448375b.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"啓動FTP服務","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令: ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"systemctl start vsftpd.service","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"什麼都沒顯示就是成功","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/6a/6aa97e406de76ac234d54337bb2d6978.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查看FTP服務監聽的端口","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"netstat -antup | grep ftp","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以看到,FTP服務已啓動,監聽的端口號爲21","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9f/9fe0fe257b3b933c818a1ab0f4ea2a3c.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"此時,vsftpd默認已開啓匿名訪問功能,無需輸入用戶名和密碼即可登錄FTP服務器,但沒有修改或上傳文件的權限","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"4. 配置 vsftpd","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"上面已經介紹了vsftpd服務有 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"匿名用戶模式","attrs":{}}],"attrs":{}},{"type":"text","text":" 和 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"本地用戶模式","attrs":{}}],"attrs":{}},{"type":"text","text":" 兩種訪問方式,下面我們一起來了解一下這兩種方式的配置方式","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.1 匿名用戶模式","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"修改配置文件 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"vsftpd.conf","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"vim /etc/vsftpd/vsftpd.conf","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"vim大家應該都很熟悉了,不會的同學可以到網上找一下教程學習一下基本操作","attrs":{}}]}],"attrs":{}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們先找到 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"anon_upload_enable=YES","attrs":{}}],"attrs":{}},{"type":"text","text":"(匿名上傳權限) 這一行,按 i 進行並編輯,取消其註釋,然後按 ESC 鍵退出編輯模式,輸入 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":":wq","attrs":{}}],"attrs":{}},{"type":"text","text":" 保存並退出 ","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/c7/c7ee576c642f53b52226455fe24c32e2.pngr","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"更改 /var/ftp/pub 目錄的權限,爲FTP用戶添加寫權限","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"chmod o+w /var/ftp/pub/","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運行後如下","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a5/a54e76532be3587af2cdc4848a713f04.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"重啓FTP服務","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"systemctl restrat vsftpd.service","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/11/1147b819dfb1927c187fcd1b6b02d7df.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"配置後以後我們通過瀏覽器訪問一下,打開瀏覽器,輸入網址 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"ftp://:FTP端口","attrs":{}}],"attrs":{}},{"type":"text","text":",例如我訪問的地址爲 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"ftp://139.196.209.227:21","attrs":{}}],"attrs":{}},{"type":"text","text":"。可以看到,我們無需輸入用戶名和密碼即可訪問,訪問結果如下: ","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/72/72b762c3555fbee070eda957c9ff1a42.pngr","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.2 本地用戶模式","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"4.2.1 用戶 & 文件目錄創建","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲FTP服務創建一個Linux用戶","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"adduser ftptest","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/42/427dc3196ca925dddd141877aad511fa.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲剛纔創建的用戶設置密碼","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"passwd ftptest","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在輸密碼的時候出於安全保護屏幕上是不顯示的","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/0b/0bc8fd917c08757625049e7850052b35.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"創建一個供FTP服務使用文件目錄","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"mkdir /var/ftp/test","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/1f/1fb65f4635aceaacff1f163206ba8a23.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"更改 /var/ftp/test 目錄的擁有者爲 ftptest【剛纔創建的用戶】","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"chown -R ftptest:ftptest /var/ftp/test","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":"none"},"content":[{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ad/ad4f5628b6dbd7fc049e6a5ac09c53f3.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"4.2.2 vsftpd.conf 文件配置【主動模式 or 被動模式】","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在配置之前先大概瞭解一下主動模式和被動模式","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"主動模式:服務器的數據端口20主動連接客戶端的數據端口【對FTP服務器端的管理有利,對客戶端的管理不利】","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"被動模式:客戶端主動跟服務器的20端口進行連接【對FTP客戶端的管理有利,對服務器端的管理不利】","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"4.2.2.1 主動模式","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令如下,直接複製過去運行就ok了","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":" sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf #禁止匿名登錄FTP服務器 \n sed -i 's/listen=NO/listen=YES/' /etc/vsftpd/vsftpd.conf #監聽IPv4 sockets \n sed -i 's/listen_ipv6=YES/#listen_ipv6=YES/' /etc/vsftpd/vsftpd.conf #關閉監聽IPv6 sockets \n sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/' /etc/vsftpd/vsftpd.conf #全部用戶被限制在主目錄 \n sed -i 's/#chroot_list_enable=YES/chroot_list_enable=YES/' /etc/vsftpd/vsftpd.conf #啓用例外用戶名單 \n sed -i 's/#chroot_list_file=/chroot_list_file=/' /etc/vsftpd/vsftpd.conf #指定例外用戶列表文件,列表中的用戶不被鎖定在主目錄 \n echo \"allow_writeable_chroot=YES\" >> /etc/vsftpd/vsftpd.conf \n echo \"local_root=/var/ftp/test\" >> /etc/vsftpd/vsftpd.conf #設置本地用戶登錄後所在的目錄\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"4.2.2.2 被動模式","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令如下","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":" sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf #禁止匿名登錄FTP服務器 \n sed -i 's/listen=NO/listen=YES/' /etc/vsftpd/vsftpd.conf #監聽IPv4 sockets \n sed -i 's/listen_ipv6=YES/#listen_ipv6=YES/' /etc/vsftpd/vsftpd.conf #關閉監聽IPv6 sockets \n sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/' /etc/vsftpd/vsftpd.conf #全部用戶被限制在主目錄 \n sed -i 's/#chroot_list_enable=YES/chroot_list_enable=YES/' /etc/vsftpd/vsftpd.conf #啓用例外用戶名單 \n sed -i 's/#chroot_list_file=/chroot_list_file=/' /etc/vsftpd/vsftpd.conf #指定例外用戶列表文件,列表中的用戶不被鎖定在主目錄 \n echo \"allow_writeable_chroot=YES\" >> /etc/vsftpd/vsftpd.conf \n echo \"local_root=/var/ftp/test\" >> /etc/vsftpd/vsftpd.conf #設置本地用戶登錄後所在的目錄 \n \n echo \"pasv_enable=YES\" >> /etc/vsftpd/vsftpd.conf #開啓被動模式 \n echo \"pasv_address=\" >> /etc/vsftpd/vsftpd.conf #本教程中爲ECS服務器彈性IP \n echo \"pasv_min_port=20\" >> /etc/vsftpd/vsftpd.conf #設置被動模式下,建立數據傳輸可使用的端口範圍的最小值 \n echo \"pasv_max_port=21\" >> /etc/vsftpd/vsftpd.conf #設置被動模式下,建立數據傳輸可使用的端口範圍的最大值\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"4.2.3 例外用戶名單","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在 /etc/vsftpd 目錄下創建 chroot_list 文件,在文件中寫入例外用戶名單","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"vim /etc/vsftpd/chroot_list","attrs":{}}],"attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用vim命令編輯 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"chroot_list","attrs":{}}],"attrs":{}},{"type":"text","text":"文件,添加例外用戶名單。此名單中的用戶不會被鎖定在主目錄,可以訪問其他目錄。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"注意:沒有例外用戶時,也必須創建chroot_list文件,內容可爲空。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最後重啓FTP服務即可","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"命令:","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"systemctl restart vsftpd.service","attrs":{}}],"attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"4.2.4 測試","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"同樣,我們在瀏覽器輸入 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"ftp://:FTP端口","attrs":{}}],"attrs":{}},{"type":"text","text":" ,我訪問的地址爲 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"ftp://139.196.209.227:21","attrs":{}}],"attrs":{}},{"type":"text","text":"。可以看到,在設置爲本地用戶模式的情況下,我們需要輸入用戶名和密碼登錄纔可進行訪問,我們輸入剛纔創建的用戶 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"ftptest","attrs":{}}],"attrs":{}},{"type":"text","text":" 和自己設置好的密碼進行訪問 ","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a3/a3a6ecabc294d84439fdf7ffd06f230a.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"登錄成功後界面如下,此時我們就可以對FTP文件進行相應權限的操作 ","attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/6c/6c55084d635889431e0e640a8e1fa7c0.pngr","alt":null,"title":null,"style":null,"href":null,"fromPaste":false,"pastePass":false}}]}]}],"attrs":{}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章