欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

用Linux架設(shè)FTP服務(wù)器(下)_Ftp服務(wù)器教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!
 

message

“message”設(shè)置當(dāng)用戶登錄或轉(zhuǎn)到一個目錄的時候會收到什么消息。可以設(shè)定多個消息。命令的格式為:

message <path> <when>

<path>表示需要顯示的文件的完整路徑名,<when>和“readme”中的<when>意思一樣。

還需要注意的是消息文件的路徑名也是相對于匿名ftp目錄的。

例如:

message /home/ftp/.welcome.msg LOGIN

compress、tar、chmod、delete、overwrite、rename

如果這些都不設(shè)置,那么就使用默認(rèn)值,也就是對所有人都是“yes”。下面例子中的設(shè)置的意思是給guest組chmod、delete、overwrite和rename文件的權(quán)力,所有人都可以使用compress和tar。

例如:

compress yes all

tar yes all

chmod yes guest

delete yes guest

overwrite yes guest

rename yes guest

log commands

因為安全上的原因需要記錄用戶使用的每一個命令。“l(fā)og commands”的格式是:

log commands <typelist>

<typelist>是用逗號隔開的字串,表示哪些用戶的命令需要記錄下來,字串的取值可以是:anonymous、guest或real。

例如:要記錄real和guest用戶的每一個命令,可以這么表示:

log commands real,guest

這些記錄都保存在“/var/log/message”文件中。

log transfers

因為安全文件需要把文件的傳輸都記錄下來。“l(fā)og transfers”的格式是:

log transfers <typelist> <directions>

<typelist>是用逗號隔開的字串,表示哪些用戶的命令需要記錄下來,字串的取值可以是:anonymous、guest或real。<direction>也是用逗號隔開的字串,設(shè)置需要記錄的文件傳輸?shù)姆较颍梢赃x擇的兩個傳輸方向是“inbound”(向內(nèi))和 “outbound”(向外)。

例如,用下面表示記錄所有real和guest用戶的“inbound”和“outbound”方向的文件傳輸:

log transfers real,guest inbound,outbound

這些記錄保存在“/var/log/xferlog”文件中。

guestgroup

這個命令用來設(shè)置guest組,每一行只能有一個成員。

例如:

guestgroup ftpadmin

guestgroup webmaster

log security

用來設(shè)置記錄real、guest或anonymous用戶違反安全規(guī)則的行為。

log security <typelist>

<typelist>是用逗號隔開的字串,字串的取值可以是:anonymous、guest或real。“real”表示真正在Ftp服務(wù)器上有帳號的用戶,“anonymous”表示匿名用戶,“guest”表示guest用戶。

例如:

log security real,guest

restricted-uid、restricted-gid、guest-root

這些用來設(shè)置是否允許real和guest用戶訪問家目錄之外的目錄。格式為:

guest-root <root-dir>

restricted-uid <uid-range>

restricted-gid <gid-range>

例如:

guest-root /home/ftp ftpadmin webmaster

restricted-uid ftpadmin webmaster

restricted-gid adminftp webmaster

<root-dir>設(shè)置chroot環(huán)境的用戶路徑。在一行里可以有多個uid地范圍。如果為用戶設(shè)置了guest-root,那么該用戶的家目錄就在“<root-dir>/etc/passwd”文件中設(shè)定,而“/etc/passwd”文件中的設(shè)定是無效的。當(dāng)“ftpadmin”和 “webmaster”被改變了根目錄(chrooted)到“/home/ftp”目錄下,他們就被限制在各自的家目錄下而不能訪問別人的文件。

greeting

設(shè)置用戶登錄時候的歡迎信息。格式為:

greeting full|brief|terse

“greeting full”是默認(rèn)的設(shè)置顯示主機(jī)名和ftp daemon地版本,“greeting brief”顯示主機(jī)名,“greeting terse”簡單地顯示“FTP server ready”。

例如:

greeting terse

keepalive <yes|no>

設(shè)置socket的TCP SO_KEEPALIVE參數(shù)。這樣在必要的時候可以斷開網(wǎng)絡(luò)連接。“yes”有效,“no”無效。最好設(shè)成“yes”:

Keepalive yes

配置“/etc/ftphosts”文件

“/etc/ftphosts”文件為每一個用戶建立規(guī)則,指定允許用戶從某個主機(jī)登錄ftp服務(wù)器,或者不允許用戶從某個主機(jī)登錄Ftp服務(wù)器。

創(chuàng)建“ftphosts”文件(touch /etc/ftphosts),加入下面這幾行:

# Example host access file

#

# Everything after a ‘#‘ is treated as comment,

# empty lines are ignored

allow ftpadmin 208.164.186.1 208.164.186.2 208.164.186.4

把文件的權(quán)限改為600:

[root@deep]# chmod 600 /etc/ftphosts

每一行可能是:

allow <username> <addrglob>

deny <username> <addrglob>

“allow”允許用戶用<username>用戶名,從<addrglob>地址訪問Ftp服務(wù)器。<addrglob>可以包含多個地址。

“deny”禁止用戶名為<username>的用戶,從<addrglob>地址訪問Ftp服務(wù)器。<addrglob>可以包含多個地址。

配置“/etc/ftpusers”文件

“/etc/ftpusers”文件設(shè)置哪些用戶不允許連接到Ftp服務(wù)器。

創(chuàng)建“ftpusers”文件(touch /etc/ftpusers),加入下面這幾行:

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

把文件的權(quán)限設(shè)成600:

[root@deep]# chmod 600 /etc/ftpusers

配置“/etc/ftpconversions”文件

“/etc/ftpconversions”是用來控制當(dāng)傳輸文件的時候是否進(jìn)行壓縮。

創(chuàng)建“ftpconversions”文件(touch /etc/ftpconversions),在文件中加入:

:.Z: : :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS

: : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS

:.gz: : :/bin/gzip -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP

: : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP

: : :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR

: : :.tar.Z:/bin/tar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS

: : :.tar.gz:/bin/tar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP

: : :.crc:/bin/cksum %s:T_REG::CKSUM

: : :.md5:/bin/md5sum %s:T_REG::MD5SUM

把文件的屬性改為600:

[root@deep]# chmod 600 /etc/ftpconversions

配置“/etc/pam.d/ftp”文件

配置“/etc/pam.d/ftp”文件使其支持PAM安全驗證。

創(chuàng)建“ftp”文件(touch /etc/pam.d/ftp)并加入:

#%PAM-1.0

auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

auth required /lib/security/pam_pwdb.so shadow nullok

auth required /lib/security/pam_shells.so

account required /lib/security/pam_pwdb.so

session required /lib/security/pam_pwdb.so

配置“/etc/logrotate.d/ftpd”文件

配置“/etc/logrotate.d/ftpd”文件使得日志文件每周自動循環(huán)更新。

創(chuàng)建“ftpd”文件(touch /etc/logrorate.d/ftpd)并加入:

/var/log/xferlog {

# ftpd doesn‘t handle SIGHUP properly

nocompress

}

配置ftp使其使用inetd超級服務(wù)器(用于實現(xiàn)tcp-wrappers)

tcp-wrappers用來啟動和中止ftpd服務(wù)。當(dāng)inetd執(zhí)行的時候,它會從默認(rèn)為“/etc/inetd.conf”的配置文件讀入配置信息。配置文件中每一行中的項用TAB或空格隔開。

編輯inetd.conf文件(vi /etc/inetd.conf),加入并驗證是否存在下面這一行: ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a

注意:更新完“inetd.conf”文件之后要發(fā)給inetd一個SIGNUP信號,運行下面的命令:

[root@deep /root]# killall -HUP inetd

編輯“hosts.allow”文件(vi /etc/hosts.allow)加入這一行:

in.ftpd: 192.168.1.4 win.openarch.com

這表示IP地址為“192.168.1.4”并且主機(jī)名為“win.openarch.com”的計算機(jī)允許訪問Ftp服務(wù)器。

FTP管理工具

ftpwho

ftpwho顯示當(dāng)前連接到Ftp服務(wù)器上的所有用戶。這個命令菜單輸出類似“/bin/ps”的輸出,其格式為:

<pid> <time> <tty> <connection details>

其中<pid>表示ftp daemon用來處理這次文件傳輸?shù)倪M(jìn)程號,<time>表示用戶什么時候連接到Ftp服務(wù)器上,<tty>總是用問號(?)表示因為是通過ftp而不是 telnet連接,<connection details>告訴連接是來自哪里、用戶是誰以及用戶現(xiàn)在在干什么。

下面是ftpwho輸出的一個例子:

[root@deep]# ftpwho

Service class openarch:

5443 ? S 0:00 ftpd: win.openarch.com: admin: IDLE

- 1 users ( 20 maximum)

可以看到現(xiàn)在有一個用戶登錄(最多可以有20個用戶同時登錄),這個用戶的用戶名是admin來自win.openarch.com。

ftpcount

ftpcount是ftpwho的簡化版,只顯示登錄到Ftp服務(wù)器的用戶數(shù)以及最多允許多少個用戶登錄。下面是一個例子:

[root@deep]# ftpcount

Service class openarch - 1 users ( 20 maximum)

保證Ftp服務(wù)器的安全

首先確保已經(jīng)創(chuàng)建了“/etc/ftpusers”文件,這個文件用來設(shè)置不允許哪些用戶登錄Ftp服務(wù)器,其中至少要包括:root、bin、 daemon、adm、lp、sync、shutdown、halt、mail、news、uucp、operator、games、nobody以及所有Linux發(fā)行商在系統(tǒng)中提供的默認(rèn)帳號。

如果想禁止匿名ftp服務(wù),把ftp用戶從password文件中移去,再用下面的命令確定在系統(tǒng)中沒有安裝anonftp-version.i386.rpm軟件包:

[root@deep]# rpm -q anonftp.

upload命令

在默認(rèn)情況下,WU-FTPD 服務(wù)器給所有的guest用戶上載的權(quán)限。當(dāng)用戶登錄的時候,被改變根目錄(chroot)到“/home/ftp”就不能訪問這個目錄之外的地方。但是 “/home/ftp”目錄中的一些地方還是需要保護(hù),不能讓用戶隨便訪問。在我們配置的Ftp服務(wù)器中為“/home/ftp”目錄下的“bin”、 “etc”、“dev”和“l(fā)ib”目錄。我們不允許用戶上載文件到這些目錄。所以我們要為這些目錄設(shè)置訪問權(quán)限,可以在 “/etc/ftpaccess”文件中設(shè)置上載權(quán)限。在我們的例子中是這樣設(shè)置的:

upload /home/ftp/* / no

upload /home/ftp/* /etc no

upload /home/ftp/* /dev no

upload /home/ftp/* /bin no (require only if you are not using the “--enable-ls” option)

upload /home/ftp/* /lib no (require only if you are not using the “--enable-ls” option)

noretrieve命令

最好禁止某些用戶從“/home/ftp”目錄下的某些子目錄中下載文件,可以用“noretrieve”命令在“/etc/ftpaccess”文件中設(shè)置。

noretrieve /home/ftp/etc

noretrieve /home/ftp/dev

noretrieve /home/ftp/bin (require only if you are not using the “--enable-ls” option)

noretrieve /home/ftp/lib (require only if you are not using the “--enable-ls” option)

“.notar”文件

無論是否允許即時的目錄打包(on-the-fly tar),都必須保證用戶不能打包(tar)禁止上載的目錄。在“/home/ftp”目錄的每個子目錄中都創(chuàng)建“.notar”文件。

[root@deep]# touch /home/ftp/.notar

[root@deep]# chmod 0 /home/ftp/.notar

[root@deep]# touch /home/ftp/etc/.notar

[root@deep]# chmod 0 /home/ftp/etc/.notar

[root@deep]# touch /home/ftp/dev/.notar

[root@deep]# chmod 0 /home/ftp/dev/.notar

[root@deep]# touch /home/ftp/bin/.notar (require only if you are not using the “--enable-ls” option)

[root@deep]# chmod 0 /home/ftp/bin/.notar (require only if you are not using the “--enable-ls” option)

[root@deep]# touch /home/ftp/lib/.notar (require only if you are not using the “--enable-ls” option)

[root@deep]# chmod 0 /home/ftp/lib/.notar (require only if you are not using the “--enable-ls” option)

這些長度為0的“.notar”文件會使一些瀏覽器和ftp代理(proxy)出現(xiàn)混亂,要解決這個問題必須把它們標(biāo)識為禁止下載。在“/etc/ftpaccess”文件中加入這一行:

noretrieve .notar

安裝到系統(tǒng)中的文件

> /etc/ftphosts

> /etc/ftpusers

> /etc/ftpaccess

> /etc/pam.d/ftp

> /etc/ftpconversions

> /etc/ftpgroups

> /etc/logrotate.d/ftpd

> /usr/bin/ftpcount

> /usr/bin/ftpwho

> /usr/man/man1/ftpcount.1

> /usr/man/man1/ftpwho.1

> /usr/man/man5/ftpaccess.5

> /usr/man/man5/ftphosts.5

> /usr/man/man5/ftpconversions.5

> /usr/man/man5/xferlog.5

> /usr/man/man8/ftpd.8

> /usr/man/man8/ftpshut.8

> /usr/man/man8/ftprestart.8

> /usr/sbin/in.ftpd

> /usr/sbin/ftpshut

> /usr/sbin/ckconfig

> /usr/sbin/ftprestart

> /usr/sbin/xferstats

> /usr/sbin/wu.ftpd

> /usr/sbin/in.wuftpd

> /var/log/xferlog


來源:網(wǎng)絡(luò)搜集//所屬分類:Ftp服務(wù)器教程/更新時間:2013-04-15
相關(guān)Ftp服務(wù)器教程