tid=21211&參考:
+ q' f8 B8 ]4 M9 \http://www.111cn.net/sys/CentOS/88456.htm
8 w, M( @1 w; u$ Lhttps://www.centos.bz/2011/03/centos-pureftpd-install/$ F, s3 J: p' R) W- f& l
9 g% v% m: Y- \+ ~7 R% G通过Yum安装Pure-ftpd的详细步骤如下:
7 ], L9 Q4 K. u2 r) z7 z1 x5 u0 t; U
步骤一:配置yum源以下是針對 CentOS 6.X* w1 c2 e9 U6 o. u5 m
备份(如有配置其他epel源), t: u$ \$ U' B1 B1 I9 i5 E2 g
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup% ]5 J( Y7 Y a) r- t* a
下载新repo 到/etc/yum.repos.d/" ~0 N- q5 `/ y4 N# p) {8 Q: U) [' s
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo7 \4 z' e# r# T. n) m
yum makecache
9 ^! r9 x; e/ \9 H1 `* o1 J0 }4 ?7 O4 c4 M" N. o$ }1 ]
以下是針對 CentOS 5.X" R* W. B; ?0 a4 H
cd /etc/yum.repos.d/) n0 E4 J7 m1 G# N) ^2 o
wget http://centos.karan.org/kbsingh-CentOS-Extras.repo! e3 ^" c: ~$ i# ~* S% k
6 h3 y. R, ]" ]- D) q必需激活kbs-CentOS-Testing庫。打開kbsingh-CentOS-Extras.repo文件,把enabled=0改成enabled=1。7 W5 ^1 O" o" r) f% G$ \/ [
vi kbsingh-CentOS-Extras.repo
% r+ S1 G1 o5 W! y- z. g/ j- [kbs-CentOS-Testing]
- name=CentOS.Karan.Org-EL$releasever - Testing
- gpgcheck=1
- gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
- enabled=1
- baseurl=http://centos.karan.org/el$releasever/extras/testing/$basearch/RPMS/
複製代碼 接着我們導入GPG key到軟件庫- rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
複製代碼 如果步驟一失敗的話,使用以下指令:7 D# Q# `$ k; V( s
rpm -Uvh ftp://ftp.trychlos.org/pub/CentOS/6.3/pcalfs/x86_64/RPMS/epel-release-6-7.noarch.rpm (CentOS 6.7)' P8 H9 I' B6 n( h' `, Z. ?
上列是以CentOS 6.7,假如是CentOS 6.8 則在google 搜尋 epel-release-6-8.noarch.rpm的載點,以此類推
3 ^" r) H* o% B( R: |/ q8 |6 [
0 t( W! e+ k: K0 k9 p/ [9 ? ^9 O! R步骤二:yum安装
t4 f! S4 i$ d |% @/ J. L% zyum install pure-ftpd -y. x8 K$ S, W! l& m$ w
" {* u7 B# B2 g& h# y$ h" N4 e步骤三:修改配置文件. Q! B( ?5 {) n c+ F1 W
vim /etc/pure-ftpd/pure-ftpd.conf, m: y2 }' i0 x! a3 F, h( k
9 r: {. h- X) d
PureDB /etc/pure-ftpd/pureftpd.pdb1 H3 K, Z- y' z0 u% @( X7 ~$ ]: q& v" ]
#去掉这行注释,指定路径,PureDB用户数据库文件
& t3 ^) Z+ v C3 ~4 ^VerboseLog yes0 F2 o) i# C7 l Q0 k7 {( T
#开启日志 /var/log/pureftpd.log, o- Q( k0 o8 a6 [
NoAnonymous yes
/ l; |) g6 U; W; _7 J#拒绝匿名用户登录5 ^( A* l k& j$ @5 b" _
PassivePortRange 48000 50000
! Y7 C' e1 R9 W' P4 p#使用被动模式,限制端口。$ h. r: r" R3 Q( R1 v
- L* A: b' S4 }, I
5 @2 }; l) E7 c4 k$ k
& P3 \2 l3 G0 C! R+ |" T% M
步骤四:配置防火墙策略5 F* O1 X* [: P) }
iptables -A INPUT -p tcp --dport 21 -j ACCEPT8 R+ \% G3 @1 j7 c& N" t
iptables -A INPUT -p tcp --dport 48000:50000 -j ACCEPT: e6 B5 k4 y: k2 ^, E: r
; _# Z, l* q% [' t. ~" u步骤五:启动pure-ftpd
* F' X5 p+ j) e& v. u/ v" i' z' Hchkconfig pure-ftpd --level 345 on (設定每次開機自動執行)
- C [. K" x+ T% E2 B* C假如找不到chkconfig,which chkconfig 可以找到它的目錄位置,一般應該在/sbin,如果/sbin也沒有則表示沒安裝chkconfig" ^. k- W2 B/ p5 t' s
yum install chkconfig 安裝chkconfig
+ t0 y+ Q( G# A" C假如安裝完也 chkconfig: command not found
1 `( G7 W3 \1 Z/ w p+ t: i7 t則做一個連結 % i" \! V( i2 V2 S
ln -s /sbin/chkconfig /usr/bin/; D- c' _, C2 L% r/ V* F( X
5 g8 X1 Q: a8 k$ m# q2 @. G' T
/etc/init.d/pure-ftpd start 或 service pure-ftpd start使用源碼安裝請參考 http://www.111cn.net/sys/CentOS/88456.htm假如 service pure-ftpd start 也顯示 service: command not found) }/ J- |/ }1 \& X! l* A* a" g2 u
也作一個連結
" A( M, E$ ^7 g+ eln -s /sbin/service /usr/bin/; [* o7 d& n. C
! L& s8 J3 W3 J安裝 ftp client :6 H, h9 g) b' z# }+ c; }- c
yum install ftp -y
5 L( n- I' s* E5 Z3 R/ c! o/ i! y. z3 d# b
註:
! ^9 w3 x- \# @
% |7 f' }. H$ o# i+ C1.4 T6 [3 i/ m! }/ Z$ k4 L7 c+ u
when login ftp show error:
( [0 J1 a: G# l# k0 j530 Login authentication failed( l! `. y( v1 u! k4 F, D
Login failed.
. y) G% U! [5 _# b+ e1 l
/ x8 @9 |7 S$ ?8 F- K4 N( ?8 J4 o& X/ k+ o/ q, m
check /var/log/secure& Y2 D, e' Y4 [: c
Nov 3 10:03:44 DLTB-2475 pure-ftpd: pam_listfile(pure-ftpd:auth): Couldn't open /etc/ftpusers! O; u8 J1 W; g2 ]3 C
Nov 3 10:03:44 DLTB-2475 pure-ftpd: PAM audit_log_acct_message() failed: Operation not permitted3 K7 R; N1 x/ r4 w5 B+ p
* Z0 `9 x) G- XSol:4 c/ Q, ]4 G/ r6 `
vi /etc/pure-ftpd/pure-ftpd.conf- `' a9 Y+ c$ x- s
將PAMAuthentication 認證改成 UnixAuthentication認證 ,即) q& y: q9 N! u) v: a/ {% p/ H( |
#PAMAuthentication yes 註解掉
, o( _) _ k2 @' H) pUnixAuthentication yes 取消註解
+ g( [& m! O F' k* F7 a9 yservice pure-ftpd restart
& z' }( W( X( P4 T t3 t0 w3 M& n8 m4 T6 J1 Q+ l0 L
2.5 ^& J+ D0 x' d( v
When login ftp server from remote host show errors:
L% T# V) v: | O5 cconnect: No route to host& s7 v6 l: z0 }2 q
原因是防火牆擋住了,或iptable没有預設NAT處理,SOL:
4 s E. `( o* m7 estop iptables or 適當設定 iptables
9 h* P, n- i8 @8 M或
1 [3 x/ N/ a, B4 @) hvi /etc/sysconfig/iptables-config% y8 s8 J: S7 y
更改 IPTABLES_MODULES=”” 為 IPTABLES_MODULES=”ip_nat_ftp ip_conntrack_ftp”' S' y9 ~6 y# T5 J, M: O J. ~
service iptables reload& @6 @/ S" D, {8 m& [+ v0 n
3 O+ X' e+ J# K+ \, u3.
) ]- V- c2 w9 T, L) i421 Unable to read the indexed puredb file (or old format detected) - Try pure-pw mkdb( U/ l! i5 g2 A9 C/ C
Login failed.
. u/ F+ ~, W! ?& k |0 B$ U. k
1 o& R- V- S! y7 y" LSOL:" @8 m7 c$ k7 o% v! M P
vi /etc/pure-ftpd/pure-ftpd.conf
p# ? m% G" h3 _" G7 W將 PureDB /etc/pure-ftpd/pureftpd.pdb 註解掉: @& {, q/ j" s: f. n& E1 A: T( {
4.( {0 K7 h8 j3 }
ftp> put file
3 a. }: ? ]9 K0 s- ylocal: file remote: file: t- `4 _, b% s2 u
227 Entering Passive Mode (122,117,11,31,193,78)
, y2 u- W: z" }) J" U# o( d553 Can't open that file: Permission denied
- u0 H+ F" H1 P2 e$ q- B0 v. P$ c. W: o( }1 z! f' i# z
SOL:
9 y' v8 {! O+ m& Y. B" qls -l /home/user1& _2 G& a, L( _/ k. [: i' v1 B; i
drwxr-xr-x. 2 root root 4096 2016-01-17 04:46 user1+ _$ U6 i/ v' j) n& n
chown user1:user1 /home/user1
9 N9 l' Y" `7 s3 b+ ?9 m7 e
3 B3 E* l, O" B; t9 F2 u[ftp 指令]7 U! ^* n% M4 S5 q. g
lcd 改變local目錄
4 J, D8 n& J5 z' {+ [0 S. dlls 查看local目錄或檔案 (等同 !ls)
2 } r2 \3 X% y0 H$ D3 @0 R+ p! w
$ {0 t+ Q2 P5 x! L1 }' \' Q* Y* k3 }$ x' o H# C F1 T
- x f/ A$ Y! b+ h3 k
% G' K4 h5 V8 K' A7 B |