歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> ProFTPD部署指南

ProFTPD部署指南

日期:2017/3/3 16:36:59   编辑:關於Linux

服務器環境:RHEL5.4

下載ProFTP:

# wget ftp://ftp1.hk.proftpd.org/proftpd/distrib/source/proftpd-1.3.4a.tar.bz2

1.FTP要求:

公司四個部門:運維部、開發部、銷售部、行政部

各部門用戶訪問FTP後可以看到所有目錄,僅可以訪問本部門的目錄

需要FTP日志功能

FTP認證方式基於文件認證方式

共享目錄:/var/ftp

2.解壓文件:

# tar -xjf proftpd-1.3.4a.tar.bz2 -C /usr/src/

# cd /usr/src/proftpd-1.3.4a/

安裝前請先閱讀INSTALL與README文件

3.安裝ProFTPD:

#./configure --help 查看幫助選項

######################################################################################

以下為部分選項說明:

--prefix=PREFIX指定安裝路徑(--prefix=/usr/local/)
--sysconfdir=DIR 指定FTP服務配置文件路徑(--sysconfdir=/etc)
--localstatedir=DIR 指定運行狀態的文件存放位置(默認/var/proftpd)
--with-modules=mod_ldap指定加載功能模塊
--enable-memcache 支持緩存功能
--enable-nls 支持多語言環境(如中文),安裝完成後在主配置文件中需要指定字符編碼(UseEncoding UTF-8 CP936)
--enable-openssl 支持TLS加密FTP服務
--enable-shadow支持使用/etc/shadow驗證用戶密碼
######################################################################################################
注:需要GCC編譯器
#./configure --prefix=/usr/local/proftpd --sysconfdir=/etc/ --enable-nls --enable-openssl --enable-shadow
#make
#make install
#PATH=echo$PATH:/usr/local/proftpd/bin添加環境變量
#useradd -M -s /sbin/nologin proftp

創建啟動用戶及組(該用戶無法登錄系統,沒有宿主目錄)

4.建立共享目錄,修改配置文件:

#mkdir  -p  /var/ftp/{運維部,開發部,銷售部,行政部}
#useradd -M -s /sbin/nologin yunwei
#useradd -M -s /sbin/nologin kaifa
#useradd -M -s /sbin/nologin xiaoshou
#useradd -M -s /sbin/nologin xingzheng
#chmod 777 /var/ftp/運維部
#chmod 777 /var/ftp/開發部
#chmod 777 /var/ftp/銷售部
#chmod 777 /var/ftp/行政部
#vim /etc/proftpd.conf 以下為配置文件原文(行號僅為參考值)
******************************************************************************************************
1# This is a basic ProFTPD configuration file (rename it to
2# 'proftpd.conf' for actual use. It establishes a single server
3# and a single anonymous login. It assumes that you have a user/group
4# "nobody" and "ftp" for normal operation and anon.
5
6ServerName"ProFTPD Default Installation"
客戶端連接後顯示的字符
7ServerTypestandalone
服務啟動模式
8DefaultServeron
9
10# Port 21 is the standard FTP port.
11Port21端口
12
13# Don't use IPv6 support by default.
14UseIPv6off禁用IPv6
15
16# Umask 022 is a good standard umask to prevent new dirs and files
17# from being group and world writable.
18Umask022 權限掩碼
19
20# To prevent DoS attacks, set the maximum number of child processes
21# to 30. If you need to allow more than 30 concurrent connections
22# at once, simply increase this value. Note that this ONLY works
23# in standalone mode, in inetd mode you should use an inetd server
24# that allows you to limit maximum number of processes per service
25# (such as xinetd).
26MaxInstances30 並發進程30個(防DoS攻擊)
27
28# Set the user and group under which the server will run.
29Usernobody 啟動服務的用戶
30Groupnobody 啟動服務的組
31
32# To cause every FTP user to be "jailed" (chrooted) into their home
33# directory, uncomment this line.
34#DefaultRoot ~共享根目錄(默認為用戶家目錄)
35
36# Normally, we want files to be overwriteable.
37AllowOverwriteon是否允許使用文件覆寫權限
38
39# Bar use of SITE CHMOD by default
40<Limit SITE_CHMOD>權限設置
41 DenyAll
42</Limit>
43
44# A basic anonymous configuration, no upload directories. If you do not
45# want anonymous users, simply delete this entire <Anonymous> section.
46<Anonymous ~ftp>
47 Userftp
48 Groupftp
49
50 # We want clients to be able to login with "anonymous" as well as "ftp"
51 UserAliasanonymous ftp用戶別名
52
53 # Limit the maximum number of anonymous logins
54 MaxClients10 最大客戶端連接數
55
56 # We want 'welcome.msg' displayed at login, and '.message' displayed
57 # in each newly chdired directory.
58 DisplayLoginwelcome.msg顯示登錄信息
59 DisplayChdir.message
60
61 # Limit WRITE everywhere in the anonymous chroot
62 <Limit WRITE>權限設置
63 DenyAll
64 </Limit>
65</Anonymous>

******************************************************************************************************
該文件格式:
##########################################################################
# 全局設置參數值 #
# 全局設置參數值 #
# #
# <Directory "路徑">指定路徑相關設置,可以使用Limit語法限制目錄權限 #
# ... ... #
# ... ... #
# </Directory> #
# #
# #
# #
# <anonymouse "路徑">匿名共享路徑相關設置(包括權限設置) #
# </anonymouse> #
##########################################################################
Limit權限說明:
#########################################################################
#CWD : Change Working Directory進入該目錄 #
#MKD : Make Directory創建目錄#
#RNFR : Rename from更名#
#DELE : Delete刪除文件#
#RMD : Remove Directory刪除目錄#
#READ : 可讀 #
#WRITE: 可寫#
#STOR : 可上傳#
#RETR : 可下載 #
#DIRS :允許列出目錄#
#LOGIN:允許登錄#
#ALL : 全部#
#########################################################################

修改後有效的配置文件內容,部分內容為添加內容(#開始的部分為注釋):

    6ServerName"ProFTPD Default Installation"
7ServerTypestandalone
8DefaultServeron
9 UseEncoding UTF-8 CP936支持的編碼格式(中文)
11Port21
12 AllowRetrieveRestarton 允許斷點繼傳(上傳)
13 AllowStoreRestarton 允許斷點繼傳(下載)
14UseIPv6off
18Umask022
19 RootLoginoff禁止root登錄ftp
26MaxInstances30
27 SystemLog/var/log/proftp.log
產生獨立的日志文件
28TransferLog/var/log/proftp.log
記錄用戶下載的日志信息
#####如果想指定自己的日志格式可以結合(ExtendLog,LogFormat)兩個選項設置
29Userproftp 設置啟動用戶為proftp
30Groupproftp 設置啟動組為proftp
34DefaultRoot /var/ftp 指定共享根目錄為/var/ftp
37AllowOverwriteon
46#<Anonymous ~ftp>該部分全部#注釋,取消匿名訪問功能
47# Userftp
48# Groupftp
51# UserAliasanonymous ftp
54# MaxClients10
58# DisplayLoginwelcome.msg
59# DisplayChdir.message
62# <Limit WRITE>
63# DenyAll
64# </Limit>
65#</Anonymous>

以下內容為設置權限,為手動添加內容

所有用戶可以看到所有部門的文件夾,僅可以訪問自己部門的目錄

*****************************************************************************************************
67 RequireValidShell off用戶登錄是否需要shell(對虛擬用戶很重要)
68 AuthUserFile /usr/local/proftpd/ftpd.passwd
通過文件認證用戶登錄,需要ftpasswd命令創建該文件
69<Directory "/var/ftp/*">
70<Limit CWD READ> 允許所有人可以查看根目錄
71AllowAll
72</Limit>
73</Directory>
74<Directory "/var/ftp/運維部">
75<Limit CWD MKD RNFR READ WRITE STOR RETR>
76DenyAll 拒絕所有人往該目錄下執行Limit後的操作指令
77</Limit>
78<Limit DELE>
79DenyAll 禁止任何人在該目錄下刪除文件
80</Limit>
81<Limit CWD MKD RNFR READ WRITE STOR RETR>
82AllowUser yunwei 僅允許yunwei用戶可以執行Limit後的所有指令
83</Limit>
84</Directory>
85<Directory "/var/ftp/開發部">
86<Limit CWD MKD RNFR READ WRITE STOR RETR>
87DenyAll
88</Limit>
89<Limit DELE>
90DenyAll
91</Limit>
92<Limit CWD MKD RNFR READ WRITE STOR RETR>
93AllowUser kaifa
94</Limit>
95</Directory>
96<Directory "/var/ftp/行政部">
97<Limit CWD MKD RNFR READ WRITE STOR RETR>
98DenyAll
99</Limit>
100<Limit DELE>
101DenyAll
102</Limit>
103<Limit CWD MKD RNFR READ WRITE STOR RETR>
104AllowUser xingzheng
105</Limit>
106</Directory>
107<Directory "/var/ftp/銷售部">
108<Limit CWD MKD RNFR READ WRITE STOR RETR>
109DenyAll
110</Limit>
111<Limit DELE>
112DenyAll
113</Limit>
114<Limit CWD MKD RNFR READ WRITE STOR RETR>
115AllowUser xiaoshou
116</Limit>
117</Directory>
******************************************************************************************************

5.創建虛機帳號

ftpasswd命令格式說明

(該命令可以創建用戶文件、組文件,默認創建的用戶文件為ftpd.passwd):

--passwd  創建密碼文件,即AuthUserFile指定的文件
--group 創建組文件
--name 指定創建的用戶名
--uid 指定用戶虛擬UID
--gid 指定虛擬GID
--home 指定用戶家目錄
--shell 指定用戶Shell
--file 指定創建的文件名
#ftpasswd --passwd --name=yunwei --uid=1000 --home=/home/nohome --shell=/bin/false

6.啟動FTP服務:

#/usr/local/proftpd/sbin/proftpd

成功驗證!!!!

這裡僅以用戶為實驗環境,需要實現組功能的情況可以自行探索...

支持開源

本文出自 “丁丁歷險” 博客,請務必保留此出處http://manual.blog.51cto.com/3300438/760048

Copyright © Linux教程網 All Rights Reserved