FTP伺服器(File Transfer Protocol)
FTP伺服器是一種應用非常廣泛的檔案傳輸服務,Linux的預設FTP服務為vsftpd,這是一款安全、可靠、易用的程式。
步驟一:安裝服務
1. 準備網絡環境:2台Linux主機,一台為伺服器端,另一台為用戶端。在伺服器端配yum倉庫
2. 安裝服務
[root@svr5 桌面]# yum -y install vsftpd
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!
3. 開啟服務
[root@svr5 桌面]# service vsftpdstart
為 vsftpd 啟動 vsftpd: [确定]
4. FTP的配置檔案
1)主配置檔案:/etc/vsftpd/vsftpd.conf
2)黑名單檔案:/etc/vsftpd/ftpusers
3)黑/白名單檔案:/etc/vsftpd/user_list
步驟二:用戶端測試
1. 建立測試檔案,建立檔案/var/ftp/ftptest.txt/home/lisi/lisi.txt
[root@svr5 ftp]# touch ftptest.txt
[root@svr5 ftp]# touch /home/lisi/lisi.txt
2. windows 客服端測試

3. Linux用戶端驗證
[root@pc205 桌面]# ftp 192.168.4.5 //登入ftp
Connected to 192.168.4.5 (192.168.4.5).
Name (192.168.4.5:root): ftp //輸入預設的匿名使用者
331 Please specify the password.
Password: //任意密碼
230 Login successful. //登入成功
ftp> pwd
257 "/" //匿名使用者的根目錄路徑為/var/ftp
主配置檔案(vsftpd.conf)解析:
anonymous_enable=YES //(預設)允許匿名登入
local_enable=YES //容許本地使用者登入
anon_upload_enable=YES //允許匿名上傳檔案
anon_mkdir_write_enable=YES //允許匿名建立目錄
anon_other_write_enable=YES //允許其他寫入權限
write_enable=YES //(預設)允許寫入(全局)
anon_umask=022 //設定上傳檔案權限掩碼
chroot_local_user=YES //禁锢本地使用者家目錄
userlist_enable=YES //(預設)啟用user_list清單檔案
userlist_deny=NO //将user_list作為白名單
max_clients=20 //允許的最大并發連接配接數
max_per_ip=2 //每個IP位址最多允許多少連接配接
anon_max_rate=50000 //匿名下載下傳速度,Byte/s
local_max_rate=200000 //本地使用者下載下傳速度,Byte/s
ftpusers 黑名單---à userlist_enable=YES/NO 這個參數決定黑名單是否生效
user_list--à userlist_deny=YES/NO “YES”是作為黑名單“NO”作為白名單
步驟三:故障排除
在Linux客服端輸入ftp指令是出現以下錯誤
[root@pc205 桌面]# ftp 192.168.4.5
bash: ftp: command not found
原因:用戶端沒有安裝ftp程式
[root@pc205 桌面]# yum -y install ftp
說明:
以匿名使用者登入時根目錄在/var/ftp目錄下,以本地使用者登入時根目錄在使用者的家目錄下