今天在自己的FC4機器上安裝FTP伺服器,讓他人通過FTP共用資料.
在網上查閱了一翻,比較常用的FTP伺服器有:Wu-FTP, ProFTP, VSFTP.
我選中了VSFTP,不為別的,因為它叫Very Secure嘛.它的設計本來就是以安全性來考慮的.
去主要站台下了VSFTP的2.04版本,不大,一百多KB. 是:ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.0.4.tar.gz
下完了之後make,在make install之前根做N步工作.
1)需要添加nobody使用者 #useradd nobody
2)如果make沒產生/usr/share/empty目錄的話,建立該目錄, #mkdir /usr/share/empty
3)如果FTP需要匿名(anonymous)使用者的話,需要建立ftp這個使用者,並指定其HOME目錄為/var/ftp #useradd -d /var/ftp ftp
4)更改/var/ftp檔案夾的歸屬,並更改存取許可權 #chown root.root /var/ftp #chmod 755 /var/ftp
5)make install
make install之後,需根手工把vsftpd.conf拷貝到/etc目錄下去,其INSTALL檔案是這麼說的:
"make install" doesn't copy the sample config file. It is recommended youdo this:
cp vsftpd.conf /etc
下面就可以了.但是啟動FTP服務可以有兩種方式.一種是Smoke test (without an inetd). 另一種是Run from an inetd of some kind
關於inted方式,我一直找不到我的FC4裡面有這個服務,也找不到有這個檔案.難道我沒裝這個包?雖然通過inted方式有更多的功能,但只好用smoke test功能.
修改/etc/vsftpd.conf 然後在最後一行加入 listen=YES
然後,啟動/usr/local/sbin/vsftpd & ,當然,必須要保證沒有任何程式佔用21連接埠.
輸入ftp 172.0.0.1
會出現:
Connected to localhost (127.0.0.1).
220 (vsFTPd 1.1.1)
Name (localhost:chris): ftp
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
.....
問題:
1.查看有沒有程式佔用某個連接埠,並關閉其連接埠:
netstat -anp | more
其中會顯示出某個進程的PID,連接埠號碼,等等資訊,根關閉其連接埠.一種方法是用Sercive 程式名 stop 關閉,另一種是用kill -9 PID 關閉.
2.Linux有預設的防火牆,別的主機登入不上,報NO route to host
案頭->系統設定->安全層級有相應設定,也可以使用iptables命令,如:
[root@t81a143 ~]# iptables -F
[root@t81a143 ~]# iptables -X
[root@t81a143 ~]# iptables -t nat -F
[root@t81a143 ~]# iptables -t nat -X
[root@t81a143 ~]# iptables -t mangle -F
[root@t81a143 ~]# iptables -t mangle -X