天天看點

Proftpd 安裝配置

今天安裝配置proftpd-1.3.4a ,現将我的一些過程和了解記錄如下:

1、 下載下傳安裝

http://www.proftpd.org  可下載下傳最新版本

安裝時./configure  --prefix=PREFIX 選項。我是安裝到/opt/proftpd

--sysconfdir=DIR 配置檔案路徑

2、 配置

[root@localhost home]# cd /opt/proftpd/

[root@localhost proftpd]# ls

bin  etc  include  lib  libexec  sbin  share  sys.log  var

建立nologin和nohome使用者,預設沒有nogroup組,需建立該組。

[root@localhost proftpd]# cat /etc/passwd | grep ftp

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin

ftp01:x:507:100:ftpsvruser01:/home/ftp01:/sbin/nologin

ftp02:x:508:100:ftpsvruser01:/home/ftp02:/sbin/nologin

ftp03:x:509:100:ftpsvruser01:/home/ftp03:/sbin/nologin

主要的配置在./etc/proftpd.conf上

<VirtualHost IP>

......

</VirtualHost>

<Anonymous  "路徑名" >  

.....

</Anonymous>

<Directory "路徑名"OR Incoming>

...

</Directory>#關于匿名使用者的設定

<Limit 限制動作>

..

</Limit>

<Directory >是對目錄的通路權限控制,<Limit>是進行一些限制

網上配置很多,我這裡隻想說明點是:

預設匿名通路隻有一個,但用VirtualHost可以用port來設定多個。或多個IP。

虛拟ftp一般用于一台ftp伺服器有好多ip位址,或者ftp用不同的端口。

即<Anonymous  "路徑名" >  

虛拟路徑可以有多個,附件conf裡有VirtualHost配置執行個體,conf是我的應用系統配置執行個體,當然有寫使用者名改了而已。

配置前調試:[root@localhost proftpd]# ./sbin/proftpd -t  檢測conf檔案文法錯誤

[root@localhost proftpd]# ./sbin/proftpd -n  實時stderr,便于調試配置。-c 是配置檔案調用。

 網上有将proftpd注冊為services或xinet啟動的腳本和方法,我不羅嗦了,search吧。

# To cause every FTP user to be "jailed" (chrooted) into their home

# directory, uncomment this line.

DefaultRoot /home/ftp/ftp01 ftp01

DefaultRoot /home/ftp/ftp02 ftp02

DefaultRoot /home/ftp/ftp03 ftp03

DefaultChdir /home/ftp/ftp01

DefaultChdir /home/ftp/ftp02

DefaultChdir /home/ftp/ftp03

這幾個設定的含義是:用ftp01登入,會自動跳到/home/ftp/ftp01目錄下,proftpd預設是跳到/home/$user 使用者的家目錄下

但隻有一個起作用,即ftp02、ftp03都會跳轉到/home/ftp/ftp01下,那如何要ftp02自動跳轉到/home/ftp/ftp02下呢,用VirtualHost,配置執行個體在conf附件裡就不多寫了。

匿名登入:

關鍵的語句:RequireValidShell    off  

在<Anonymous  "路徑名" >裡沒有這句會匿名登入不成功。

# A basic anonymous configuration, no upload directories.  If you do not

# want anonymous users, simply delete this entire <Anonymous> section.

<Anonymous /home/ftp/anon>

  User                    ftp

  Group                ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"

  UserAlias            anonymous ftp

  # Limit the maximum number of anonymous logins

  MaxClients            20

  # We want 'welcome.msg' displayed at login, and '.message' displayed

  # in each newly chdired directory.

  DisplayLogin            welcome.msg

  DisplayChdir            .message

  AnonRequirePassword    off

# 必須要如下項,不然匿名無法登入

  RequireValidShell    off

  # Limit WRITE everywhere in the anonymous chroot

  <Limit WRITE>

    AllowAll

  </Limit>

  <Limit STOR>

    AlLowALL

  <Limit DELE>

    AllowALl

   </Limit>

  <Limit LOGIN /home/ftp/anon>

   AllowALL

  </Limit>    

有用的幾個指令:

ftpshut:關閉FTP服務,并在/etc下生成檔案shutmsg。要重新開放FTP服務,把/etc/shutmsg删除。

2、ftpcout:FTP伺服器線上人數資訊顯示。

3、ftpwho:FTP伺服器線上人員名單

4、./sbin/ftpshut

這個指令還是比較實用的,因為你可能需要不斷的調整你的伺服器,而這個指令就非常靈活,可以在不停止proftpd程序的前提下,定時停止ftp連接配接

ftpshut [ -l min ] [ -d min ] time [ warning-message ... ]

-l min: 在ftp關閉服務之前的幾分鐘内,嘗試建立新的ftp連接配接均不被接受

-d min: 在ftp關閉服務之前的幾分鐘内,已經建立的ftp連接配接将被中止

time: 在多少時間後,伺服器将關閉ftp服務,格式有兩種

+number 經過number分鐘後關閉

MMHH 在今天MM:HH伺服器将關閉

注意,這裡我們用這個指令是把ftp服務給停了,但實際的proftpd程序還沒停止,是以一般調試ftp會使用到這個指令。

舉例:

再經過30分鐘後,FTP服務将關閉,在這之前的20分鐘不可接受任何新的ftp連接配接,已經建立的在服務關閉前10分鐘強制斷線,并在用戶端顯示“FTP Server Will shutdown at time”

ftpshut -l 20 -d 10 +30 "FTP Server Will shutdown at time"

.ftpaccess 檔案

文檔說如同apache的.htacess,就是在ftpsvr的目錄下,建立一個.ftpaccess的檔案,預設隐藏。作用如同proftpd.conf配置檔案裡一樣的配置效果。使用者認證後對目錄權限的通路會首先通路.ftpaccess,再通路proftpd.conf的配置。下面的英文說的很清楚。

<b><code>.ftpaccess</code> files</b>

A <code>.ftpaccess</code> file is meant to function like Apache's <code>.htaccess</code> file: a file that acts as free-floating section of the server's configuration file. If a <code>.ftpaccess</code> file is present in a directory in which the server looks, it will parse that <code>.ftpaccess</code> file as a configuration file, and act accordingly. Only some configuration directives are allowed in the <code>.ftpaccess</code> context, though. The advantage of having this capability is that users can customize how the server treats directories that are under the user's control via files placed in those directories, instead of allowing the user to modify the main server configuration file itself. The disadvantage is that a user is capable of possibly overriding a configuration value that was set in the main configuration file for a specific purpose.

The server treats a directory that contains a <code>.ftpaccess</code> file exactly as if the configuration directives in that file had been placed in a <code>&lt;Directory&gt;</code> section in the main <code>proftpd.conf</code> file. For example, if there is a <code>/home/users/bob</code> directory on your system, and in that directory there was a <code>.ftpaccess</code> file that contained:

it would be treated exactly as if:

was written into

<code>proftpd.conf</code>

.

&lt;Limit&gt;的一些option

CMD:Change Working Directory 改變目錄

MKD:MaKe Directory 建立目錄的權限

RNFR: ReName FRom 更改目錄名的權限

DELE:DELEte 删除檔案的權限

RMD:ReMove Directory 删除目錄的權限

RETR:RETRieve 從服務端下載下傳到用戶端的權限

STOR:STORe 從用戶端上傳到服務端的權限

READ:可讀的權限,不包括列目錄的權限,相當于RETR,STAT等

WRITE:寫檔案或者目錄的權限,包括MKD和RMD

DIRS:是否允許列目錄,相當于LIST,NLST等權限,還是比較實用的

ALL:所有權限

LOGIN:是否允許登陸的權限針對這些設定,又有如下具體的配置:AllowUser 針對某個使用者允許的Limit

DenyUser 針對某個使用者禁止的Limit

AllowGroup 針對某個使用者組允許的Limit

DenyGroup 針對某個使用者組禁止的Limit

AllowAll 針對所有使用者組允許的Limit

DenyAll 針對所有使用者禁止的Limit同時,可以針對單獨的使用者來限制速度TransferRate STOR|RETR 速度(Kbytes/s) user 使用者

變量内容:

%T 目前的時間

%F 所在硬碟剩下的内容

%C 目前所在目錄

%R Client端的主機名稱

%L Server端的主機名稱

%U 使用者帳号名稱

%M 最大允許聯機人數

%N 目前的主機聯機人數

%E FTP主機管理者email

%i 本次上傳的檔案數目

%o 本次下載下傳的檔案數量

%t 本次上傳+下載下傳的檔案數量

網上說&lt;Limit LOGIN&gt;是一個用來限制登陸的特殊指令,在&lt;limit&gt;中用這個,可以禁止或者允許連接配接進來。但是,如果不在Server config,&lt;VirtualHost&gt; 或者&lt;Anonymous&gt;中使用的話,他将失去效用,或者說被忽略掉(比如在&lt;Directory&gt;中使用就是無效的),确實是這樣的。

http://miaomiao7988.blogcn.com/articles/proftpd%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0.html 、

這個頁面可供大家了解,如果大家對字元配置不熟,可先配置gproftpd,圖形界面的,配置完後,再看配置檔案,就學得比較快了

就不截圖了,太懶了,文檔和conf檔案在附件裡。

      本文轉自fuhaixiong 51CTO部落格,原文連結:http://blog.51cto.com/heliy/185565,如需轉載請自行聯系原作者