Tải bản đầy đủ - 0 (trang)
Chapter 24.  Running an FTP Server

Chapter 24.  Running an FTP Server

Tải bản đầy đủ - 0trang

24.1.Introduction

ProFTPDisahighlyconfigurable,GPL-licensedFTPserver.It

strivestobetheFTPserverequivalentoftheApacheweb

server.ItmightnotbetheleanestandmeanestFTPserverout

there,butitiscertainlyoneofthemostflexibleones.ProFTPD

isused,forexample,bySourceForge.

ProFTPDisavailablefromhttp://www.proftpd.org.



24.2.CompilingandInstalling

IfyourdistributiondoesnotcomewithProFTPD,youcaneither

compileandinstallitfromthesourcetarballoruseapackage

appropriateforyourdistribution.RPM-baseddistributionscan

installtheRPMfromhttp://proftpd.org.Debianuserscanenter

apt-getinstallproftpd.



24.2.1.RPMInstall

UnlessthereisaspecificbinaryRPMforyourdistribution,

downloadthesourceRPMandbuildit:rpmbuild--rebuild

proftpd-1.2.10-1.src.rpm.Thiswillproducetwoinstallable

RPMs:proftpd-1.2.10-1.i586.rpm,whichcontainstheactual

software,andproftpd-inetd-1.2.10-1.i586.rpm,whichcontains

thesupportfilesforrunningProFTPDfromxinetd.TheproftpdinetdRPMisoptional,andwewillnotcoveritinthisbook.

InstallthemainRPMafterthebuildcompletes:



#rpm-ivh/usr/src/packages/RPMS/i586/proftpd-1.2.10-1.i586.rp



TheRPMsseemtobetailoredforRedHat,soifyouuseSUSE,

youneedtodoafewadjustments.Thercscriptinstallsto

/etc/rc.d/init.d/proftpd,whichisn'ttherightlocationonSUSE;

also,thescriptitselfwillnotwork.Instead,usethefollowing

replacementscriptandcopyitto/etc/rc.d/proftpd:

#!/bin/sh

#

#StartupscriptforProFTPD

#

#chkconfig:3458515



#description:ProFTPDisanenhancedFTPserverwith\

#afocustowardsimplicity,security,andeaseofconf

#ItfeaturesaveryApache-likeconfigurationsyntax,

#andahighlycustomizableserverinfrastructure,\

#includingsupportformultiple'virtual'FTPservers,

#anonymousFTP,andpermission-baseddirectoryvisibil

#processname:proftpd

#config:/etc/proftpd.conf

PROFTPD=/usr/sbin/proftpd

PATH="$PATH:/usr/sbin"

if[-f/etc/sysconfig/proftpd];then

./etc/sysconfig/proftpd

fi

./etc/rc.status

rc_reset

#Seehowwewerecalled.

case"$1"in

start)

echo-n"Startingproftpd:"

startproc$PROFTPD$OPTIONS

rc_status-v

;;

stop)

echo-n"Shuttingdownproftpd:"

killproc-TERM$PROFTPD

rc_status-v

;;

try-restart)

$0status

iftest$?=0;then

$0restart

else

rc_reset#Notrunningisnotafailure.



fi

#Rememberstatusandbequiet

rc_status

;;

status)

checkproc$PROFTPD

rc_status-v

;;

restart)

$0stop

$0start

rc_status

;;

reload)

echo-n"Re-readingproftpdconfig:"

killproc-HUP$PROFTPD

rc_status-v

;;

suspend)

hashftpshut>/dev/null2>&1

if[$?=0];then

if[$#-gt1];then

shift

echo-n"Suspendingwith'$*'"

ftpshut$*

else

echo-n"SuspendingNOW"

ftpshutnow"Maintananceinprogress"

fi

else

echo-n"Nowaytosuspend"

fi

echo

;;

resume)

if[-f/etc/shutmsg];then

echo-n"Allowingsessionsagain"



rm-f/etc/shutmsg

else

echo-n"Wasnotsuspended"

fi

echo

;;

*)

echo-n"Usage:$0{start|stop|restart|try-restart|status|r

hashftpshut

if[$?=1];then

echo'}'

else

echo'|suspend}'

echo'suspendacceptsadditionalargumentswhicharepass

fi

exit1

esac

rc_exit



Ofcourse,thiscouldbefixedinalaterversion.



24.2.2.CompilingfromSource

Downloadthetarball,unpack,configure,andbuild:

$tarxfjproftpd-1.2.10.tar.bz2

$cdproftpd-1.2.10

$./configure--prefix=/usr/local/packages/proftpd

$make



Then,asroot,runmakeinstall.Thiswillinstalleverythingto

/usr/local/packages/proftpd/.







24.3.RunningProFTPD



Startingtheserver

Whenthercscriptisinplace,theservercanbestartedwith

/etc/rc.d/proftpdstart(/etc/init.d/proftpdstartonDebian).



Stoppingtheserver

ToshuttheFTPdaemondown,run/etc/rc.d/proftpdstop.



Temporarilysuspendingtheserver

With/etc/rc.d/proftpdsuspendyoucanstopProFTPDfrom

acceptingnewconnections.Userswhotrytologinwillbe

greetedwithabannertellingthemthattheserverisdown

formaintenance.Toresumenormaloperations,run

/etc/rc.d/proftpdresume.



Debugging

WhiletroubleshootingorwritingtheProFTPDconfiguration

file,itisoftenusefultogetsomeextrainformationabout

whatisgoingon.proftpd-vvwillprintoutsomeversion

information,proftpd--nodaemonwillrunthedaemon

withoutbecomingabackgroundprocess,andproftpd-twill

checkthesyntaxofthecurrentconfigurationfile.Output

verbositycanbeincreasedbyrunningProFTPDlikethis:

proftpd-d9.Theoptions-d0to-d9canbecombinedwith



theotheroptions.



24.4.Configuration

24.4.1.GettingStarted

BoththeRPMandtarballinstallationsprovideadefault

configurationwithareadonlyanonymousFTPareaandfull

regularaccesstousersonthesystem.Thisisagoodstarting

pointifallyouwantistoofferanonymousFTPaccess.

TheconfigurationfileforProFTPDis/etc/proftpd.confor

$prefix/etc/proftpd.confifinstalledfromsource.The

anonymousFTPusersarechroot()edintothehomedirectoryof

theFTPuser,oftensomethinglike/srv/ftp/.

proftpd.confcontainsanumberofconfigurationdirectives.A

referenceofalldirectivescanbefoundat

http://www.proftpd.org/docs/directives/configuration_full.html.

Theconfigurationfileisdividedupintoanumberofcontexts,

eachdealingwithitsownaspectofProFTPD:



Mainserver

Thepartoftheconfigurationfilethatisnotinsideanyother

context.Thisisusedforglobalserversettingsandis

typicallyfoundatthebeginningofthefile.





Thiscontextisusedforconfigurationdetailsforan

anonymousFTPserver.Bydefault,ProFTPDwillallow

anonymousaccesswithoutapasswordandchroot()tothe



FTPdirectory.





Thiscontextisusedtospecifyconfigurationdetailsona

per-directorybasis.Thisistypicallyusedtolimitorgive

access.





ThiscontextisusedtocontrolaccesstoFTPcommandsand

groupsofFTPcommandsbasedonwhichuseristryingto

usethem.





Thiscontextisusedwithvirtualhosting(i.e.,having

ProFTPDservingonmultipleinterfaceswithdifferent

configurations).Directivesinthiscontextareusedasifthey

wereinthemainservercontext,withtheexceptionthat

theycanbeoverriddenbyanycontext.





Withcontextsitispossibletocreate

independentsetsofconfigurationsfordifferentnetwork

interfacesandports.

Thefollowingsectionspresenttwoexampleconfigurationsfor

ProFTPD:abasicUnixFTPserversetupandamoreadvanced

oneinwhichProFTPDisusingitsownuserdatabase.



24.4.2.BasicConfiguration

Theexampleconfigurationprovidesuswithbothananonymous

accessareaandaccesstothewholefilesystemforregular

users:

ServerName"ProFTPDDefaultInstallation"

ServerTypestandalone



ServerNamespecifiesthebannertextthattheuserseeswhen



accessingtheserver.ServerTypecanbeeitherstandaloneorinetd

andspecifieswhetherProFTPDislisteningforincoming

connectionsbyitselforisbeingrunfrom(x)inetd.

DefaultServeron

Port21



DefaultServeronmeansthatourserverconfigurationappliestoall



interfacesofthehost,andPortspecifiestheportProFTPDis

listeningto(port21isthestandardFTPport):

Umask022

MaxInstances30

Usernobody

Groupnogroup

AllowOverwriteon



DenyAll





Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 24.  Running an FTP Server

Tải bản đầy đủ ngay(0 tr)

×