說明: 因時間關係,沒有對具體細節作詳細說明,請參考wu-ftp FAQ以及ftpd,ftpaccess 的在線文檔(man ftpd). 一. ftp伺服器 1. inetd配置文件或xinetd.conf配置文件 /etc/inetd.conf文件內容如下: ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a /etc/xinetd.conf文件內容如下: service ftp { socket_type = stream protocol = tcp wait = no user = root #only_from = 202.118.66.0 #only_from += 192.168.1.2 #only_from += localhost server = /usr/sbin/in.ftpd server_args = -l -a } 相關文件:/etc/services ftp-data 20/tcp ftp 21/tcp 2. ftp用戶(Anonymous FTP伺服器需要用到) 文件:/etc/passwd和/etc/shadow /etc/passwd: ftp:x:500:50:Anonymous FTP User:/home/ftp:/bin/false /etc/shadow: ftp:*:10689:0:99999:7::: $finger ftp Login: ftp Name: FTP User Directory: /home/ftp Shell: /bin/false Never logged in. No mail. No Plan. 3. DNS配置 ftp IN CNAME officail.domain.name. 4. 管理員郵件別名 文件: /etc/mail/aliases (Solairs) /etc/aliases (Linux) (egrep aliases /etc/mail/sendmail.cf ) ftp-admin: real-user-name@domain.name 相關命令: newaliases, 建立郵件別名 二. 文件系統結構 1. Anonymous FTP 目錄結構 如下子目錄: bin(ls,gzip,tar等anonymous ftp用戶所要使用的二進位可執行文件) etc(passwd,group) lib(動態連接庫,ld-2.0.7.so, ld-linux.so.2, ldd ../bin/ls 等) pub(可下載文件) 2. passwd及group文件 不要使用系統的passwd及group文件,最好只放所需的用戶及組信息 passwd文件: ftpadm:x:0:0:Anonymous FTP:/home/ftp:/bin/false ftp:x:60000:60000:Anonymous FTP:/home/ftp:/bin/false group文件: ftpadmin:x:0: ftp:x:60000: 3. 文件及目錄屬性 主目錄/home/ftp 屬主root, 屬性555 bin 屬主root 組wheel或other, 屬性111 etc 同上 lib 屬主root, 屬性555 pub 屬主為root或ftp管理員,屬性555 確認不要用ftp作任何文件或目錄的屬主! [hbwork@helius /etc]$ cd /home/ftp/ [hbwork@helius ftp]$ ls -l total 4 d--x--x--x 2 root root 1024 Apr 8 17:57 bin d--x--x--x 2 root root 1024 Jun 4 15:12 etc drwxr-xr-x 2 root root 1024 Apr 8 17:57 lib dr-xr-sr-x 2 root ftp 1024 Apr 8 11:18 pub $ls -l bin [root@helius ftp]# ls -l bin/ total 250 ---x--x--x 1 root root 15236 Apr 28 1998 compress ---x--x--x 1 root root 46356 Sep 11 1998 cpio ---x--x--x 1 root root 45436 Sep 11 1998 gzip ---x--x--x 1 root root 29980 Sep 11 1998 ls ---x--x--x 1 root root 110668 Sep 11 1998 tar lrwxrwxrwx 1 root root 4 May 19 16:48 zcat -> gzip $ls -l etc total 19 -r--r--r-- 1 root root 57 Jun 4 15:12 group -r--r--r-- 1 root root 16372 Sep 11 1998 ld.so.cache -r--r--r-- 1 root root 83 Jun 4 15:12 passwd (在Solaris上建立anonymouse FTP特殊一些,請參考Wu-ftpd-faq) 4. 可選目錄 incoming Owner: root Mode:1733 (chmod 1733 incoming) 三. 測試及調試 egrep ftp /etc/inetd.conf ps ax |egrep inetd kill -HUP $PID $ftp localhost (or ftp 0) 執行ls cd get 等指令看一下結果如何 四. wu-ftpd FTP伺服器進程 增強功能: . 允許根據用戶的ip地址或主機,用戶名設置不同的類 . 根據設置的類,管理員可以控制其訪問許可權,如防止anonymous用戶 刪除文件或覆蓋已有的文件 . 可以實現自動執行uncompress,compress,tar,gzip等功能 . 可以記載所有的upload/download,及ftp client所發送的每個命令. . 允許平滑關掉ftp伺服器 相關配置文件: ftpaccess ftpconversions ftphosts ftpuser 相關命令: strings /usr/sbin/in.ftpd |egrep ftpaccess 1. 編譯 wu-ftpd 最新版本: wu-ftpd-2.5.0 ftp://ftp.dlut.edu.cn/pub/unix/ftp/servers/ $tar -zxvf wu-ftpd-2.5.0.tar.gz $cd wu-ftpd-2.5.0 建議在編譯安裝之前參考文件INSTALL,README,upload.configuration.HOWTO 如想定製自己的wu-ftpd,可編輯文件src/pathnames.h $build help 查看編譯幫助 $./build lnx $su #./build install 2. 命令行選項 -d Sends debugging information to syslog -a Enable the use of the ftpaccess file(This is the default) -A Disable the use of the ftpaccess file -L Cause ftpd to log all USER commands. -i Causes ftpd to log all incoming(upload) file in the xferlog file( See pathnames.h ) -o Causes ftpd to log all outgoing(download) files in the xferlog file 3. 文件ftpconversions doc/examples/, 用於指定get時的實時壓縮或展開(on-the-fly). 此文件不般情況下不用作修改 4. ftpaccess (1)定義類 三種用戶類型: real anonymous guest(需要提供相應的口令) 格式: class classname type[,type,...] address [ address ...] 示例: class local real *.dlut.edu.cn 202.118.66 localhost class anonymous anonymous * (2)拒絕訪問 deny *.net.cn /etc/ftpmsgs/msg.denied (3)限制訪問 limit class number times messages limit anonymous 200 SaSu limit anonymous 100 Any /etc/ftpmsgs/msg.toomany loginfails 2 tar no anonymous compress no anonymous chmod yes|no type [type ...] delete yes|no type [type ...] overwrite yes|no type [type ...] rename yes|no type [type ...] umask yes|no type [type ...] passwd-check none|trivial|rfc822 enforce|warn (5)banner 顯示在用戶login之前的信息 banner /etc/ftpmsg/banner.msg 其中banner.msg文件中可以引用如下變數: %C Current working directory %E Email address of the administrator( email ftpadm@dlut.edu.cn) %F 可當目錄下可用空間 %L hostname %M 最大允許連接數 %N 同一類中當前連接數 %R The client host'name or ip address %T Current local time %U The name the user specified at login 示例文件: Welcome to this test FTP Archive, running on %L. Please contact %E with any technical problems you may have accessing this archive. You are currently user %N out of a maximum %M users. It's %T in PRC. (6)message命令 message pathname login message pathname cwd=dir message .conents cwd=* 每改變目錄均顯示,cwd=dir只在第一次更改時顯示 (7)readme命令 readme pathname [login|cwd=dir] [class] [class] readme README* cwd=* (8)shutdown命令 (2.5.0上不正常) shutdown pathname (9)log命令 log commands type [ type ...] log transfer type [type ...] direction[,direction] (10)alias alias source: /pub/local/sw/source (11)cdpath cdpath /pub /pub1 上載控制 upload hierarchy directory yes|no owner group mode [dirs|nodirs] 下面的wu-ftpd-2.5.0 /etc/ftpaccess文件中的upload配置(大家可以試一下大工FTP 伺服器的upload,但別傳沒用的過大的文件) # FTP-home-dir archiv-dir allow? owner group mode dirs? # (as in /etc/passwd) upload /home/ftp * no upload /home/ftp /pub3/incoming/windows yes ftpadmin ftp 0664 dirs upload /home/ftp /pub3/incoming/windows/* yes ftpadmin ftp 0664 dirs upload /home/ftp /pub3/incoming/unix yes ftpadmin ftp 0666 dirs upload /home/ftp /pub3/incoming/unix/* yes ftpadmin ftp 0666 dirs upload /home/ftp /pub3/incoming/other yes ftpadmin ftp 0666 dirs upload /home/ftp /pub3/incoming/other/* yes ftpadmin ftp 0666 dirs upload /home/ftp /pub3/incoming/WDI yes ftpadmin ftp 0666 dirs upload /home/ftp /pub3/incoming/WDI/* yes ftpadmin ftp 0666 dirs 5. ftphosts文件 allow ftp *.dlut.edu.cn allow anonymous *.dlut.edu.cn deny ftp *.dlmu.edu.cn deny ftp *.dlmu.edu.cn 202.118.80.* 6.實用程序 ftpcount ftpwho ftushut 維護: 建立連接時最好使用相對路徑。 根據軟體類別建立不同的子目錄。 最好在每個目錄中建立相應的說明文件或index文件,方便用戶查找。
[火星人
]
linux FTP伺服器的安裝及管理 已經有1026 次圍觀
本文地址: http://coctec.com/docs/linux/show-post-203340.html