vsftpd自架网络安装服务器.docx

上传人:b****6 文档编号:7391275 上传时间:2023-01-23 格式:DOCX 页数:17 大小:26.28KB
下载 相关 举报
vsftpd自架网络安装服务器.docx_第1页
第1页 / 共17页
vsftpd自架网络安装服务器.docx_第2页
第2页 / 共17页
vsftpd自架网络安装服务器.docx_第3页
第3页 / 共17页
vsftpd自架网络安装服务器.docx_第4页
第4页 / 共17页
vsftpd自架网络安装服务器.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

vsftpd自架网络安装服务器.docx

《vsftpd自架网络安装服务器.docx》由会员分享,可在线阅读,更多相关《vsftpd自架网络安装服务器.docx(17页珍藏版)》请在冰豆网上搜索。

vsftpd自架网络安装服务器.docx

vsftpd自架网络安装服务器

标题:

用vsFTPd自架Linux网络安装服务器,以及Redhat局域网安装的解决办法

为了验证局域网网络安装Linux,近两天做了一个实验,目的就是为了写一个比较完整的帖子。

约定:

1。

本帖操作环境是Redhat9.0,vsFTPd的版本是Redhat9.0所带的vsftpd-1.1.3-8.i386.rpm,在安装盘的第三张中

2。

vsFTPd实现的最基本的目的:

用系统中存在的真实用户能登入FTP,能用匿名访问。

3。

本帖中vsFTPd运行模式是在standalone模式下运行的,也就是说,本帖中vsFTPd所有的功能都是在standalone模式下运行的。

至于有些功能是否能在xinetd模式下运行,您就得测试了,不能照搬照抄。

因为有些功能是必须运行在特定的模式下的。

3。

服务器的IP和和DNS设定

第一块网卡

IP:

192.168.0.1

子掩码:

255.255.255.0

网关不设置:

第二块网卡:

IP:

192.168.0.2

子掩码:

255.255.255.0

网关不设置

因为我的操作环境是一个小型的局域网,所以其它的机器的IP都是在192.168.0这个网段上。

ADSL是接在服务器的第一个网卡上。

服务器的第二个网卡是接集线器,其它的客户机都是接在集线器上。

为了能让ADSL访问internet,因为自己手动设置了IP,所以DNS也要自己来设置,DNS如下:

202.96.134.133

202.96.168.68

设置工具是:

[root@linuxsir001root]#redhat-config-network

相应参考资料:

vsFTPd官方文档:

一。

用vsFTPd来架设FTP服务器,vsFTPd服务器是目前最好的FTP服务器软件,优点是体积小,可定制强,效率高

1。

查看是否安装了vsFTPd软件

[root@linuxsir001root]#rpm-qa|grepvsftpd

如果没有任何显示,说明没有把vsFTPd安装上,如果出现的是下面的这样的提示,就证明已经安装上了。

[root@linuxsir001root]#rpm-qa|grepvsftpd

vsftpd-1.1.3-8

我以Redhat9.0,以其自带的vsFTPd包vsftpd-1.1.3-8版本来为本帖约定。

[root@linuxsir001root]#rpm-ivhvsftpd*.rpm

2。

打开vsFTPd服务器。

[root@linuxsir001root]#ntsysv

把vsftpd服务器打开,也就是在运行ntsysv命令后,把vsftpd服务选中。

[*]vsftpd

3。

运行/etc/init.d/vsftpdstart

[root@linuxsir001root]#/etc/init.d/vsftpdstart

为vsftpd启动vsftpd:

[确定]

[root@linuxsir001root]#

4。

配制vsFTPd,vsFTPd的运行有两种模式,一种是standalone"initd"模式,另外一种是xinetd模式,上面我们所说的就是standalone"initd"运行模式。

两种模式运行机制不是相同的,stardardinitd模式,适合专业FTP,且FTP总是一直有人访问,占用资源也是比较大,如果您的FTP总是有人访问和登入。

就要用这种模式。

如果您的FTP访问人数比较小,建议您用xinetd模式。

xinetd模式,是当用户请求时,vsFTPd才会启动。

不同的环境,当然得用不同的启动模式。

如果想了解更多的,请在本帖后面跟帖,我会慢慢补充xinetd模式,以及虚拟用户如何设置方面的问题。

1]我们主要把vsFTPd的配制文件改一下就行了。

配制文件在/etc/vsftpd/vsftpd.conf,用您喜欢的编辑器打开。

请参考下面的配制文件。

#Exampleconfigfile/etc/vsftpd.conf

#

#Thedefaultcompiledinsettingsareveryparanoid.Thissamplefile

#loosensthingsupabit,tomaketheftpdaemonmoreusable.

#

#AllowanonymousFTP?

anonymous_enable=YES

#

#Uncommentthistoallowlocaluserstologin.

local_enable=YES

#

#UncommentthistoenableanyformofFTPwritecommand.

write_enable=YES

#

#Defaultumaskforlocalusersis077.Youmaywishtochangethisto022,

#ifyourusersexpectthat(022isusedbymostotherftpd's)

local_umask=022

#

#UncommentthistoallowtheanonymousFTPusertouploadfiles.Thisonly

#hasaneffectiftheaboveglobalwriteenableisactivated.Also,youwill

#obviouslyneedtocreateadirectorywritablebytheFTPuser.

#anon_upload_enable=YES

#

#UncommentthisifyouwanttheanonymousFTPusertobeabletocreate

#newdirectories.

#anon_mkdir_write_enable=YES

#

#Activatedirectorymessages-messagesgiventoremoteuserswhenthey

#gointoacertaindirectory.

dirmessage_enable=YES

#

#Activateloggingofuploads/downloads.

xferlog_enable=YES

#

#MakesurePORTtransferconnectionsoriginatefromport20(ftp-data).

connect_from_port_20=YES

#

#Ifyouwant,youcanarrangeforuploadedanonymousfilestobeownedby

#adifferentuser.Note!

Using"root"foruploadedfilesisnot

#recommended!

#chown_uploads=YES

#chown_username=whoever

#

#Youmayoverridewherethelogfilegoesifyoulike.Thedefaultisshown

#below.

#xferlog_file=/var/log/vsftpd.log

#

#Ifyouwant,youcanhaveyourlogfileinstandardftpdxferlogformat

xferlog_std_format=YES

#

#Youmaychangethedefaultvaluefortimingoutanidlesession.

#idle_session_timeout=600

#

#Youmaychangethedefaultvaluefortimingoutadataconnection.

#data_connection_timeout=120

#

#Itisrecommendedthatyoudefineonyoursystemauniqueuserwhichthe

#ftpservercanuseasatotallyisolatedandunprivilegeduser.

#nopriv_user=ftpsecure

#

#EnablethisandtheserverwillrecogniseasynchronousABORrequests.Not

#recommendedforsecurity(thecodeisnon-trivial).Notenablingit,

#however,mayconfuseolderFTPclients.

#async_abor_enable=YES

#

#BydefaulttheserverwillpretendtoallowASCIImodebutinfactignore

#therequest.TurnonthebelowoptionstohavetheserveractuallydoASCII

#manglingonfileswheninASCIImode.

#Bewarethatturningonascii_download_enableenablesmaliciousremoteparties

#toconsumeyourI/Oresources,byissuingthecommand"SIZE/big/file"in

#ASCIImode.

#TheseASCIIoptionsaresplitintouploadanddownloadbecauseyoumaywish

#toenableASCIIuploads(topreventuploadedscriptsetc.frombreaking),

#withouttheDoSriskofSIZEandASCIIdownloads.ASCIImanglingshouldbe

#ontheclientanyway..

#ascii_upload_enable=YES

#ascii_download_enable=YES

#

#Youmayfullycustomisetheloginbannerstring:

#ftpd_banner=WelcometoblahFTPservice.

#

#Youmayspecifyafileofdisallowedanonymouse-mailaddresses.Apparently

#usefulforcombattingcertainDoSattacks.

#deny_email_enable=YES

#(defaultfollows)

#banned_email_file=/etc/vsftpd.banned_emails

#

#Youmayspecifyanexplicitlistoflocaluserstochroot()totheirhome

#directory.Ifchroot_local_userisYES,thenthislistbecomesalistof

#userstoNOTchroot().

#chroot_list_enable=YES

#(defaultfollows)

#chroot_list_file=/etc/vsftpd.chroot_list

#

#Youmayactivatethe"-R"optiontothebuiltinls.Thisisdisabledby

#defaulttoavoidremoteusersbeingabletocauseexcessiveI/Oonlarge

#sites.However,somebrokenFTPclientssuchas"ncftp"and"mirror"assume

#thepresenceofthe"-R"option,sothereisastrongcaseforenablingit.

#ls_recurse_enable=YES

pam_service_name=vsftpd

userlist_enable=YES

#enableforstandalonemode

listen=YES

tcp_wrappers=YES

2]更改完配制文件后,我们可以用下面的命令来重启vsFTPd服务器

[root@linuxsir001root]#/etc/init.d/vsftpdrestart

关闭vsftpd:

[确定]

为vsftpd启动vsftpd:

[确定]

[root@linuxsir001root]#

3]以匿名方式来访问测试,在text模式下:

注意:

在text模式下,要用用户名ftp,密码ftp来访问,这才是在text中匿名访问FTP。

看如下的操作:

[root@linuxsir001root]#ftp192.168.0.1

Connectedto192.168.0.1.

220(vsFTPd1.1.3)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(192.168.0.1:

root):

ftp这里写上ftp

331Pleasespecifythepassword.

Password:

[这里添写ftp的密码],匿名登入密码也是ftp

230Loginsuccessful.Havefun.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>ls

227EnteringPassiveMode(192,168,0,1,137,151)

150Herecomesthedirectorylisting.

drwxr-xr-x6004096May2513:

54RedHat90

drwxr-xr-x2004096Feb2819:

21pub

226DirectorysendOK.

ftp>

那匿名用户所访问的是哪个目录?

是/var/ftp这个目录

出现问题的解决:

有时出错,是因为没有ftp和nobody用户,所以要在系统中添加这两个用户,一般的情况下,这两个用户在系统中是存在的。

看下面的操作。

[root@linuxsir001root]#adduserftp

adduser:

userftpexists

[root@linuxsir001root]#addusernobody

adduser:

usernobodyexists

从上面的操作中可知ftp和nobody用户是存在的,所以没有必要添加ftp和nobody用户了。

如果不存在,一定要添加这两个用户,否则会出现匿名用户不能访问的情况。

4]如果要以系统中存在的普通用户登入FTP,也没有什么可以设置的,添加一个用户就行。

比如我要添加beinan这个用户,就要用下面的办法

[root@linuxsir001root]#adduserbeinan

[root@linuxsir001root]#passwdbeinan

Changingpasswordforuserbeinan.

Newpassword:

BADPASSWORD:

itdoesnotcontainenoughDIFFERENTcharacters

Retypenewpassword:

passwd:

allauthenticationtokensupdatedsuccessfully.

[root@linuxsir001root]#

这样的话,就在/home目录中出现一个beinan的用户目录:

如下:

[root@linuxsir001root]#ls/home/

beinan

如果我们想让beinan这个用户作为虚拟用户,也就是说,beinan这个用户是不能登入系统的,只能是登入FTP。

那这样的用户应该如何添加呢?

[root@linuxsir001backupNow]#adduser-gftp-s/sbin/nologinbeinan

[root@linuxsir001backupNow]#passwdbeinan

Changingpasswordforuserbeinan.

Newpassword:

Retypenewpassword:

passwd:

allauthenticationtokensupdatedsuccessfully.

[root@linuxsir001backupNow]#

注:

这仅仅是vsFTPd添加虚拟用户的一个方法,还有更好的办法需要我们去学习!

另外的办法也在测试之中。

严格上来说,这种办法不能算虚拟用户。

还有另外的一个办法,就是通过pam认证,用db_load来添加用户,目前我也弄成功了,不过相对要复杂一点。

正在测试之中。

如果我们想把用户目录定位到别的目录应该怎么办呢?

这个也比较简单,看一下useradd就比较明白了。

比如我想添加beinan这个用户,并把目录放在/opt目录中:

如下操作:

[root@linuxsir001root]#adduser-d/opt/beinanbeinan

[root@linuxsir001root]#passwdbeinan

Changingpasswordforuserbeinan.

Newpassword:

Retypenewpassword:

passwd:

allauthenticationtokensupdatedsuccessfully.

如果是添加虚拟用户,也就是不让用户登入系统,只能登入FTP的用户。

如果我们想把beinan这个用户目录定位在/opt/beinan这个目录中,根据上面的方法。

我们应该如下操作

[root@linuxsir001backupNow]#adduser-d/opt/beinan-gftp-s/sbin/nologinbeinan

[root@linuxsir001backupNow]#passwdbeinan

Changingpasswordforuserbeinan.

Newpassword:

Retypenewpassword:

passwd:

allauthenticationtokensupdatedsuccessfully.

[root@linuxsir001backupNow]#

看一下是不是已经成功添加到了beinan这个用户,并把beinan的家目录放在了/opt目录中呢?

[root@linuxsir001root]#ls/opt/

beinan

证明已经成功。

我们可以在text模式下以beinan用户登入,然后来访问ftp。

[root@linuxsir001root]#ftp192.168.0.1

Connectedto192.168.0.1.

220(vsFTPd1.1.3)

530PleaseloginwithUSERandPASS.

530PleaseloginwithUSERandPASS.

KERBEROS_V4rejectedasanauthenticationtype

Name(192.168.0.1:

root):

beinan

331Pleasespecifythepassword.

Password:

230Loginsuccessful.Havefun.

RemotesystemtypeisUNIX.

Usingbinarymodetotransferfiles.

ftp>

是不是成功了?

我们也可以用gftp来访问beinan用户,并上传相应的东西,所传上的东西就放在beinan用户所在的家目录中,普通用户的家目录在哪里,写您所用的添加用户的方法有关。

我在前面已经说了两种办法,一种是默认的添加方法,就是放在/home目录中。

在本例中,我是采用默认的添加用户的方法。

也就是不特别指定用户用户,这样的话,用户目录就在/home目录中。

比如用beinan登入FTP时,访问的就是/home/beinan这个目录。

让传的东西也在这个目录中。

那匿名用户所访问的是哪个目录呢?

应该是:

/var/ftp这个目录

5]访问ftp的几种方法

第一种方法就是text访问,也就是用ftp命令来访问。

这个前面已经说过了。

第二种方法是以客户端FTP软件来访问,在linux中有gftp。

在本例中,我的FTP地址是通过局域网访问的。

地址栏中,添上192.168.0.1,端口是21,用户名和密码的添写,如果您是用匿名登入,请不要添写用户名和密码。

如果用普通用户登入,这个是必须要用用户名和密码的。

第三种办法是和浏览器访问:

如果匿名登入,就直接用下面的方法:

ftp:

//192.168.0.1

如果是用户登入方式,应该是

ftp:

//beinan@192.168.0.1

如果想让在互联网上的用户能访问到,如果您是用ADSL来访问互联网,要查找到您的动态IP,用下面的办法

[root@linuxsir001root]#ifconfigppp0

ppp0Linkencap:

Point-to-PointProtocol

inetaddr:

218.61.7.23P-t-P:

218.61.7.1Mask:

255.255.255.255

UPPOINTOPOINTRUNNINGNOARP

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

当前位置:首页 > 高等教育 > 理学

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

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