FTP服务的配置与管理.docx

上传人:b****8 文档编号:9357167 上传时间:2023-02-04 格式:DOCX 页数:30 大小:146.20KB
下载 相关 举报
FTP服务的配置与管理.docx_第1页
第1页 / 共30页
FTP服务的配置与管理.docx_第2页
第2页 / 共30页
FTP服务的配置与管理.docx_第3页
第3页 / 共30页
FTP服务的配置与管理.docx_第4页
第4页 / 共30页
FTP服务的配置与管理.docx_第5页
第5页 / 共30页
点击查看更多>>
下载资源
资源描述

FTP服务的配置与管理.docx

《FTP服务的配置与管理.docx》由会员分享,可在线阅读,更多相关《FTP服务的配置与管理.docx(30页珍藏版)》请在冰豆网上搜索。

FTP服务的配置与管理.docx

FTP服务的配置与管理

Vsftpd服务器的配置主要通过修改其主配置文件Vsftpd.conf完成。

需要注意的是,更改vsftpd.conf文件后,必须重启Vsftpd服务才能使设置生效。

11.3.1配置vsftpd.conf文件

Vsftpd的主配置文件vsftpd.conf位于/etc/目录下。

vsftpd.conf文件决定了VsftpdFTP服务器的主要操作。

vsftpd.conf文件由若干配置选项组成,下面介绍其中重要的配置选项。

Ø   anonymous_enable=NO/YES

是否允许anonymous登录FTP服务器,默认设置为YES(允许)。

Ø   local_enable=NO/YES

是否允许本地用户登录FTP服务器,默认设置为YES(允许)。

Ø   write_enable=NO/YES

是否允许用户对FTP服务器文件具有写权限,默认设置为YES(允许)。

Ø   local_umask=022(或者其他值)

设置本地用户的文件生成掩码,默认值为077,也可以根据个人喜好将其设置为其他值。

Ø   anon_upload_enable=NO/YES

是否允许匿名用户上传文件,默认设置为YES(允许)。

Ø   anon_mkdir_write_enable=NO/YES

是否允许匿名用户创建新文件夹。

默认设置为YES(允许)。

Ø   dirmessage_enable=YES

是否激活目录欢迎信息功能,当用户首次访问服务器上某个目录时,FTP服务器将显示欢迎信息。

默认情况下,欢迎信息是通过目录下的.message文件获得的。

Ø   xferlog_enable=YES

是否启用上传和下载日志的功能。

Ø   ftpd_banner=WelcometoblahFTPservice

在FTP服务器中设置欢迎登录信息。

当用户登录到FTP服务器后,会看到欢迎信息“WelcometoblahFTPservice”。

Ø   chroot_list_enable=NO/YES

chroot_list_file=/etc/vsftpd.chroot_list

“chroot”是FTP服务器配置中的重要选项。

若“chroot_list_enable”设置为“YES”,Vsftpd将在“chroot_list_file”选项值的位置寻找chroot_list文件,“/etc/vsftpd.chroot_list”文件中包含的用户,在登录后将不能切换到自己目录以外的其他目录,由FTP服务器自动地“chrooted”到用户自己的home目录下。

这将使得chroot_list文件中的用户不能随意转到其他用户的FTPhome目录下,从而有利于FTP服务器的安全管理和隐私保护。

Ø   userlist_enable=NO/YES

userlist_deny=NO/YES

“userlist_enable”选项默认值为“NO”,此时ftpusers文件中的用户禁止登录FTP服务器。

如果userlist_enable设置为“YES”,则user_list文件中的用户允许登录FTP服务器。

而如果同时设置了userlist_deny值为“YES”,则user_list文件中的用户将不允许登录FTP服务器。

Ø   listen=YES

如果设置为“YES”,则Vsftpd将以独立模式运行,由Vsftpd自己监听和处理连接请求。

11.3.2vsftpd/ftpusers与vsfptd/user-list文件配置

在/etc/目录下的vsftpd/ftpusers和vsftpd/user-list两个文件与主配置文件中的“userlist_enable”和“userlist_deny”选项有着密切联系。

两个文件中,每个用户名需占用一行。

以下是默认情况下ftpusers文件的内容:

#Usersthatarenotallowedtologinviaftp

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

以下是默认情况下user_list文件的内容:

#vsftpduserlist

#Ifuserlist_deny=NO,onlyallowusersinthisfile

#Ifuserlist_deny=YES(default),neverallowusersinthisfile,and

#donotevenpromptforapassword.

#Notethatthedefaultvsftpdpamconfigalsochecks/etc/vsftpd/ftpusers

#forusersthataredenied.

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

比较两个文件的内容,会发现它们实际上是一样的。

在使用两个文件时的区别在于,当userlist_enable为YES时,如果一个用户名在“vsftpd/user_list”文件中,而同时“userlist_deny”选项为“YES”,则该用户在试图登录FTP服务器时,将不能够登录,甚至连输入密码的提示信息都没有,直接被FTP服务器拒绝。

而如果一个用户名在“vsftpd/ftpusers”文件中,同时“userlist_deny”选项为“YES”,则该用户在试图登录FTP服务器时,将能看到输入密码的提示,但即使正确输入密码仍然不能登录FTP服务器。

userlist_deny选项和user_list文件一起能够有效地阻止“root”、“apache”和“www”等系统用户登录FTP服务器,从而保证了FTP服务器的分级安全性。

11.3.3匿名FTP设置

在登录FTP服务器的用户不确定的情况下,应将FTP服务器设置为允许匿名账号登录的FTP服务器。

启用匿名账号,并对匿名账号服务进行管理是匿名FTP设置的主要内容。

1.启用匿名账号

启用匿名账号及之后其他配置,均需要对vsftpd.conf文件进行修改,因此,在开始配置之前应当备份/etc/vsftpd/vsftpd.conf文件,以便于在修改过程中出现无法恢复的错误时,能够恢复到初始设置。

对/etc/vsftpd/vsftpd.conf文件做如下修改:

anonymous_enable=YES

local_enable=YES

write_enable=YES

listen=YES

配置好后,需要重新启动Vsftpd。

完成上述配置后,Vsftpd将允许匿名账号登录FTP服务器,允许本地账号登录,同时允许匿名用户具有对FTP服务器文件的写权限,并且只能下载文件而不能上传。

匿名用户的口令为一个E-mail地址。

测试的结果如下:

#ftplocalhost

Connectedto.

220(vsFTPd2.0.5)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>ls

227EnteringPassiveMode(127,0,0,1,204,140)

150Herecomesthedirectorylisting.

drwxr-xr-x2004096Jan172007pub

226DirectorysendOK.

 

ftp>cdpub

250Directorysuccessfullychanged.

ftp>ls

227EnteringPassiveMode(127,0,0,1,25,100)

150Herecomesthedirectorylisting.

-rw-rw-rw-10034Sep1107:

48hello.txt

226DirectorysendOK.

ftp>gethello.txt

local:

hello.txtremote:

hello.txt

227EnteringPassiveMode(127,0,0,1,181,217)

150OpeningBINARYmodedataconnectionforhello.txt(34bytes).

226FilesendOK.

34bytesreceivedin0.0017seconds(19Kbytes/s)

 

ftp>!

ls

bridge.txthello.txtwebalizer.conf

 

ftp>putwebalizer.conf

local:

webalizer.confremote:

webalizer.conf

227EnteringPassiveMode(127,0,0,1,147,155)

550Permissiondenied.

ftp>mkdirtest

550Permissiondenied.

下面对以上测试结果做几点说明。

Ø   Name(localhost:

root):

anonymous

表示用匿名账号登录。

Ø   ftp>ls

列出匿名账号在FTP服务器上的目录。

Ø   ftp>cdpub

表示更改目录,进入pub文件夹。

Ø   ftp>gethello.txt

用匿名账号下载pub文件夹中的hello.txt文件。

Ø   ftp>!

ls

bridge.txthello.txtwebalizer.conf

显示刚才下载的文件是否已下载到本地。

Ø   ftp>putwebalizer.conf

匿名账号上传webalizer.conf文件失败,不允许匿名账号上传文件。

Ø   ftp>mkdirtest

匿名账号创建文件夹失败,不允许匿名账号建立文件夹。

2.允许匿名账号上传文件

若要允许匿名账号上传文件,需要对/etc/vsftpd/vsftpd.conf文件做如下修改:

anon_upload_enable=YES

anon_mkdir_write_enable=YES

即把文件中anon_upload_enable=YES和anon_mkdir_write_enable=YES前的“#”去掉,无须修改其他配置。

所谓能上传文件,也就是具有在FTP服务器的本地目录中新建文件和文件夹的功能。

为了测试上传文件功能,可以先在/var/ftp目录中建立一个新目录“test”,并设置该文件夹具有写权限。

Ø   创建新目录“test”,如图11.4所示。

Ø   修改test目录的权限。

在“test”上单击鼠标右键,并在弹出的快捷菜单中选择【属性】命令,打开如图11.5所示的【test属性】对话框,选择【权限】选项卡,设置相应权限。

将【所有者】设置为“ftp-FTPUser”,【群组】设置为“ftp”,并设置相应的【文件夹访问】、【文件访问】和【执行】权限。

 

图11.4新建“test”目录图11.5【test属性】对话框

Ø   重启Vsftpd服务

测试的结果如下:

#ftplocalhost

Connectedto.

220(vsFTPd2.0.5)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

 

ftp>ls

227EnteringPassiveMode(127,0,0,1,68,56)

150Herecomesthedirectorylisting.

drwxr-xr-x2004096Sep1107:

48pub

drwxr-xr-x214504096Sep1108:

09test

226DirectorysendOK.

 

ftp>cdtest

250Directorysuccessfullychanged.

ftp>mkdirincoming

257"/test/incoming"created

ftp>ls

227EnteringPassiveMode(127,0,0,1,107,221)

150Herecomesthedirectorylisting.

drwx------214504096Sep1108:

19incoming

226DirectorysendOK.

 

ftp>!

ls

1.txtbridge.txthello.txtwebalizer.conf

 

ftp>put1.txt

local:

1.txtremote:

1.txt

227EnteringPassiveMode(127,0,0,1,45,47)

150Oktosenddata.

226FilereceiveOK.

361bytessentin0.0018seconds(2e+02Kbytes/s)

ftp>ls

227EnteringPassiveMode(127,0,0,1,231,175)

150Herecomesthedirectorylisting.

drwx------214504096Sep1108:

19incoming

-rw-------11450361Sep1108:

241.txt

226DirectorysendOK.

ftp>

下面对以上测试结果做几点说明。

Ø   drwxr-xr-x214504096Sep1108:

09test

ls命令后看到前面在pub目录下创建的test目录。

Ø   ftp>cdtest

更改当前目录,进入test目录下。

Ø   ftp>mkdirincoming

257"/test/incoming"created

在test目录下创建incoming目录成功。

Ø   ftp>put1.txt

将1.txt文件上传到test目录中。

Ø   -rw-------11450361Sep1108:

241.txt

ls命令后看到1.txt文件上传成功。

3.仅允许匿名用户访问

所谓仅允许匿名用户访问,也就是指需要限制本地账号访问,因此需要对/etc/vsftpd/vsftpd.conf文件做如下修改:

#local_enable=YES

#write_enable=YES

即在文件中local_enable=YES和write_enable=YES的前面加上“#”,无须修改其他配置。

对此的测试结果如下:

#ftplocalhost

Connectedto.

220(vsFTPd2.0.5)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>cdtest

250Directorysuccessfullychanged.

ftp>bye

221Goodbye.

 

#ftplocalhost

Connectedto.

220(vsFTPd2.0.5)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

Kelly

530ThisFTPserverisanonymousonly.

Loginfailed.

ftp>userteacher

530ThisFTPserverisanonymousonly.

Loginfailed.

ftp>userroot

530ThisFTPserverisanonymousonly.

Loginfailed.

从测试结果中可以看到,除了anonymous账号可以正常登录外,其他本地账号登录均失败,服务器提示“530ThisFTPserverisanonymousonly”,即服务器仅允许匿名账号登录。

4.设置欢迎信息

常用的欢迎信息包括两种:

一种是在登录FTP服务器时显示的欢迎信息,另一种是在更改目录时显示的欢迎信息。

欢迎信息的使用,能够让用户在访问FTP服务器时感觉到更友好、更亲切。

Ø   设置登录FTP服务器时显示的欢迎信息

首先对/etc/vsftpd/vsftpd.conf文件做如下修改:

ftpd_banner=WelcometoblahFTPservice

重启Vsftpd服务后,测试结果如下:

#ftplocalhost

Connectedto.

220WelcometoblahFTPservice.

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

从测试结果中可以看到,在登录FTP服务器时,多了一行显示信息“220WelcometoblahFTPservice”。

“WelcometoblahFTPservice”即在前面为服务器设置的欢迎信息,用户可以根据需要对此欢迎信息进行修改。

Ø   设置更改目录时显示的欢迎信息

在需要设置更改目录欢迎信息的目录下,创建.message文件。

例如,在“ftp/test/”目录下新建.message文件,写入一行文字“Youarewelcome!

”,保存后关闭,如图11.6所示。

图11.6编辑.message文件内容

测试的结果如下:

#ftplocalhost

Connectedto.

220WelcometoblahFTPservice.

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(localhost:

root):

anonymous

331Pleasespecifythepassword.

Password:

230Loginsuccessful.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>ls

227EnteringPassiveMode(127,0,0,1,219,233)

150Herecomesthedirectorylisting.

drwxr-xr-x2004096Sep1107:

48pub

drwxr-xr-x314504096Sep1108:

40test

226DirectorysendOK.

ftp>cdtest

250-Youarewelcome!

250Directorysuccessfullychanged.

可以看到,当进入“test”目录后,出现“250-Youarewelcome!

”这一行欢迎文字。

用户可以根据需要修改.message文件中的内容,以显示不同的欢迎信息。

5.最大传输速率

设置最大传输速率需要对/etc/vsftpd/vsftpd.conf文件进行修改。

例如,设置匿名用户的最大传输速率为20Kbps,应添加如下语句:

anon_max_rate=20000

再如,设置本地账号最大传输率为1Mbps,应添加如下语句:

local_max_rate=1000000

6.服务器最大并发数和用户最大线程数

在/etc/vsftpd/vsftpd.conf文件中添加如下语句:

max_clients=99

max_per_ip=5

即可设置服务器允许的最大并发数为99,而每个用户同一时段的最大并发线程数为5。

7.禁止某些IP段的主机匿名访问服务器

如果希望限制某些主机对FTP服务器的匿名访问,可以采用以下方法。

Ø   确认配置文件/etc/vsftpd/vsftpd.conf中有如下语句:

tcp_wrappers=YES

该语句表明服务

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 材料科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1