歡迎您光臨本站 註冊首頁

ProFTPD部署指南

←手機掃碼閱讀     火星人 @ 2014-03-08 , reply:0

ProFTPD部署指南

伺服器環境: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 6 ServerName "ProFTPD Default Installation" 客戶端連接后顯示的字元 7 ServerType standalone 服務啟動模式 8 DefaultServer on 9 10 # Port 21 is the standard FTP port. 11 Port 21 埠 12 13 # Don't use IPv6 support by default. 14 UseIPv6 off 禁用IPv6 15 16 # Umask 022 is a good standard umask to prevent new dirs and files 17 # from being group and world writable. 18

Umask 022 許可權掩碼 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). 26 MaxInstances 30 併發進程30個(防DoS攻擊) 27 28 # Set the user and group under which the server will run. 29 User nobody 啟動服務的用戶 30 Group nobody 啟動服務的組 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. 37 AllowOverwrite on 是否允許使用文件覆寫許可權 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 User ftp 48 Group

ftp 49 50 # We want clients to be able to login with "anonymous" as well as "ftp" 51 UserAlias anonymous ftp 用戶別名 52 53 # Limit the maximum number of anonymous logins 54 MaxClients 10 最大客戶端連接數 55 56 # We want 'welcome.msg' displayed at login, and '.message' displayed 57 # in each newly chdired directory. 58 DisplayLogin welcome.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 : 全部 # ######################################################################### 修改後有效的配置文件內容,部分內容為添加內容(#開始的部分為註釋): 6 ServerName "ProFTPD Default Installation" 7 ServerType standalone 8 DefaultServer on 9 UseEncoding UTF-8 CP936 支持的編碼格式(中文) 11 Port 21 12 AllowRetrieveRestart on 允許斷點繼傳(上傳)

13 AllowStoreRestart on 允許斷點繼傳(下載) 14 UseIPv6 off 18 Umask 022 19 RootLogin off 禁止root登錄ftp 26 MaxInstances 30 27 SystemLog /var/log/proftp.log 產生獨立的日誌文件 28 TransferLog /var/log/proftp.log 記錄用戶下載的日誌信息 #####如果想指定自己的日誌格式可以結合(ExtendLog,LogFormat)兩個選項設置 29 User proftp 設置啟動用戶為proftp

30 Group proftp 設置啟動組為proftp 34 DefaultRoot /var/ftp 指定共享根目錄為/var/ftp 37 AllowOverwrite on 46 #<Anonymous ~ftp> 該部分全部#註釋,取消匿名訪問功能 47 # User ftp 48 # Group ftp 51 # UserAlias anonymous ftp 54 # MaxClients 10 58 # DisplayLogin welcome.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> 允許所有人可以查看根目錄 71 AllowAll 72 </Limit> 73 </Directory> 74 <Directory "/var/ftp/運維部"> 75

<Limit CWD MKD RNFR READ WRITE STOR RETR> 76 DenyAll 拒絕所有人往該目錄下執行Limit后的操作指令 77 </Limit> 78 <Limit DELE> 79 DenyAll 禁止任何人在該目錄下刪除文件 80 </Limit> 81 <Limit CWD MKD RNFR READ WRITE STOR RETR> 82 AllowUser yunwei 僅允許yunwei用戶可以執行Limit后的所有指令 83 </Limit> 84 </Directory> 85 <Directory "/var/ftp/開發部"> 86 <Limit CWD MKD RNFR READ WRITE STOR RETR> 87 DenyAll 88 </Limit> 89 <Limit DELE> 90 DenyAll 91 </Limit> 92

<Limit CWD MKD RNFR READ WRITE STOR RETR> 93 AllowUser kaifa 94 </Limit> 95 </Directory> 96 <Directory "/var/ftp/行政部"> 97 <Limit CWD MKD RNFR READ WRITE STOR RETR> 98 DenyAll 99 </Limit> 100 <Limit DELE> 101 DenyAll 102 </Limit> 103 <Limit CWD MKD RNFR READ WRITE STOR RETR> 104 AllowUser xingzheng 105 </Limit> 106 </Directory> 107 <Directory "/var/ftp/銷售部"> 108 <Limit CWD MKD RNFR READ WRITE STOR RETR> 109 DenyAll 110 </Limit> 111

<Limit DELE> 112 DenyAll 113 </Limit> 114 <Limit CWD MKD RNFR READ WRITE STOR RETR> 115 AllowUser 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://3310438.blog.51cto.com/3300438/760048


[火星人 ] ProFTPD部署指南已經有719次圍觀

http://coctec.com/docs/linux/show-post-46785.html