麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 服務器 > Ftp服務器 > 正文

用Linux架設FTP服務器(下)_Ftp服務器教程

2024-09-09 20:58:30
字體:
來源:轉載
供稿:網友
 

message

“message”設置當用戶登錄或轉到一個目錄的時候會收到什么消息。可以設定多個消息。命令的格式為:

message <path> <when>

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

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

例如:

message /home/ftp/.welcome.msg LOGIN

compress、tar、chmod、delete、overwrite、rename

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

例如:

compress yes all

tar yes all

chmod yes guest

delete yes guest

overwrite yes guest

rename yes guest

log commands

因為安全上的原因需要記錄用戶使用的每一個命令。“log commands”的格式是:

log commands <typelist>

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

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

log commands real,guest

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

log transfers

因為安全文件需要把文件的傳輸都記錄下來。“log transfers”的格式是:

log transfers <typelist> <directions>

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

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

log transfers real,guest inbound,outbound

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

guestgroup

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

例如:

guestgroup ftpadmin

guestgroup webmaster

log security

用來設置記錄real、guest或anonymous用戶違反安全規則的行為。

log security <typelist>

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

例如:

log security real,guest

restricted-uid、restricted-gid、guest-root

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

greeting

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

greeting full|brief|terse

“greeting full”是默認的設置顯示主機名和ftp daemon地版本,“greeting brief”顯示主機名,“greeting terse”簡單地顯示“FTP server ready”。

例如:

greeting terse

keepalive <yes|no>

設置socket的TCP SO_KEEPALIVE參數。這樣在必要的時候可以斷開網絡連接。“yes”有效,“no”無效。最好設成“yes”:

Keepalive yes

配置“/etc/ftphosts”文件

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

創建“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

把文件的權限改為600:

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

每一行可能是:

allow <username> <addrglob>

deny <username> <addrglob>

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

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

配置“/etc/ftpusers”文件

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

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

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

把文件的權限設成600:

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

配置“/etc/ftpconversions”文件

“/etc/ftpconversions”是用來控制當傳輸文件的時候是否進行壓縮。

創建“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安全驗證。

創建“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”文件使得日志文件每周自動循環更新。

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

/var/log/xferlog {

# ftpd doesn‘t handle SIGHUP properly

nocompress

}

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

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

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

注意:更新完“inetd.conf”文件之后要發給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”并且主機名為“win.openarch.com”的計算機允許訪問Ftp服務器。

FTP管理工具

ftpwho

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

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

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

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

[root@deep]# ftpwho

Service class openarch:

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

- 1 users ( 20 maximum)

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

ftpcount

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

[root@deep]# ftpcount

Service class openarch - 1 users ( 20 maximum)

保證Ftp服務器的安全

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

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

[root@deep]# rpm -q anonftp.

upload命令

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

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”文件中設置。

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”目錄的每個子目錄中都創建“.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)出現混亂,要解決這個問題必須把它們標識為禁止下載。在“/etc/ftpaccess”文件中加入這一行:

noretrieve .notar

安裝到系統中的文件

> /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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日韩在线播放中文字幕 | 久久综合一区二区 | 亚洲极色 | 在线天堂中文在线资源网 | 姑娘第5集高清在线观看 | 日韩精品一区二区三区中文 | 免费黄色在线电影 | 国产日产精品一区四区介绍 | 国产精品欧美日韩一区二区 | h色在线观看 | 人人做人人看 | 日本网站在线播放 | 性生活视频一级 | 欧美aaaaa一级毛片在线 | 草莓福利视频在线观看 | 欧美成人免费在线视频 | 精品一区久久久 | 国产精品久久国产精麻豆96堂 | 91精品国产91久久久久久丝袜 | 久久精品性视频 | 久久久久亚洲a | 羞羞的视频免费在线观看 | 12av电影| 亚洲成人精品在线 | 麻豆porn| 护士hd老师fre0性xxx | 美女网站色免费 | 日本高清视频网站www | 黄视频免费在线 | 久久在线精品视频 | 日本a大片 | 嗯哈~不行好大h双性 | 国产91丝袜在线熟 | 成人午夜免费福利 | 亚洲第一成人在线 | 成人精品aaaa网站 | 一本色道久久99精品综合蜜臀 | 国产午夜亚洲精品理论片大丰影院 | 色播视频在线播放 | 亚洲电影在线观看高清免费 | 日韩黄色一区 |