0139-0141.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 507 行

HTML
507
字号




<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:FTP</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=08 //-->

<!-- PAGES=0131-0152 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0135-0138.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0142-0144.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-139"><P>Page 139</P></A>













<P>where &lt;n&gt; is the number of attempts. For example, the following line disconnects a user

from the FTP server after three failed attempts:

</P>





<!-- CODE SNIP //-->

<PRE>

loginfails 3

</PRE>

<!-- END CODE SNIP //-->











<H5><A NAME="ch08_ 14">

private

</A></H5>









<P>You might find it convenient to be able to share files with other users via FTP without

having to place the file in a 100 percent public place or having to give these users a real account on

the server. The clients use the SITE GROUP and SITE

GPASS commands so that they can change into privileged groups that require passwords.

</P>









<P>For your FTP server to support this capability, you need to set the

private flag using the command

</P>





<!-- CODE SNIP //-->

<PRE>

private &lt;switch&gt;

</PRE>

<!-- END CODE SNIP //-->











<P>where &lt;switch&gt; is either the string YES to turn it on or

NO to turn it off.

</P>









<P>Because you need to require passwords for these special groups, you need to use the

/etc/ftpgroups file. The format of an access group in

/etc/ftpgroups is

</P>





<!-- CODE SNIP //-->

<PRE>

access_group_name:encrypted_password:real_group

</PRE>

<!-- END CODE SNIP //-->











<P>where access_group_name is the name that the client uses to reference the special

group, encrypted_password is the password users need to supply (via

SITE GPASS) to access the group, and real_group is the actual group referenced in the

/etc/group file.

</P>







<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

TIP

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

To create the encrypted_password entry, use the UNIX

crypt function. To make generating the encrypted password easier, use the following Perl script:





<!-- CODE //-->

<PRE>

#!/usr/bin/perl

print &quot;Enter password to encrypt: &quot;;

chop ($password=&lt;STDIN&gt;);

print &quot;The encrypted password is: &quot;,crypt($password,$password);

</PRE>

<!-- END CODE //-->



</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

<H4>

Controlling Banner Messages

</H4>









<P>It is often useful to provide messages to FTP users when they connect to your site or specify

a special action. These commands allow you to specify these instances as well as the

corresponding messages. Using them is a great way to make your site self-documenting.

</P>









<H5><A NAME="ch08_ 15">

banner

</A></H5>









<P>The banner command allows you to display a sign onscreen before the client has to provide

a login and password combination. The format of this command is

</P>





<!-- CODE SNIP //-->

<PRE>

banner &lt;path&gt;

</PRE>

<!-- END CODE SNIP //-->





<A NAME="PAGENUM-140"><P>Page 140</P></A>













<P>where &lt;path&gt; is the full pathname of the file you want to display. Consider this example:

</P>





<!-- CODE SNIP //-->

<PRE>

banner /home/ftp/.banner

</PRE>

<!-- END CODE SNIP //-->











<H5><A NAME="ch08_ 16">

email

</A></H5>









<P>The email command allows you to specify the site maintainer's e-mail address. Some

error messages or information requests provide the information given in this line on demand.

The default value in the /etc/ftpaccess file is

root@localhost.

</P>









<P>The format of the email command is

</P>





<!-- CODE SNIP //-->

<PRE>

email &lt;address&gt;

</PRE>

<!-- END CODE SNIP //-->











<P>where &lt;address&gt; is the full e-mail address of the site maintainer.

</P>









<P>Creating an e-mail alias &quot;FTP&quot; that forwards to the system administrators is generally

good practice. Providing this kind of information in the sign-on banner is also a good idea so

that users know whom to contact if they cannot log in to the system.

</P>









<H5><A NAME="ch08_ 17">

message

</A></H5>









<P>The message command allows you to set up special messages to be sent to the clients when

they either log in or change into a certain directory. You can specify multiple messages. The

format of this command is

</P>





<!-- CODE SNIP //-->

<PRE>

message &lt;path&gt; &lt;when&gt; {&lt;class&gt; ...}

</PRE>

<!-- END CODE SNIP //-->











<P>where &lt;path&gt; is the full pathname to the file to be displayed,

&lt;when&gt; is the condition under which to display the message, and

&lt;class&gt; is a list of classes to which this message

command applies.

</P>









<P>The &lt;when&gt; parameter should take one of two forms: either

LOGIN or CWD=&lt;dir&gt;. If it is LOGIN, the message is displayed upon a successful login. If the parameter is set to

CWD=&lt;dir&gt;, then the message is displayed when clients enter the

&lt;dir&gt; directory.

</P>









<P>The &lt;class&gt; parameter is optional. You can list multiple classes for a certain message.

This capability is useful if you want only certain messages going to anonymous users and so on.

</P>









<P>The message file itself (specified by

&lt;path&gt;) can contain special flags that the FTP server

substitutes with the appropriate information at runtime. These options are as follows:

</P>



<HR>





<TABLE WIDTH="360">



<TR><TD>

Option

</TD><TD>

Description

</TD></TR>





<TR><TD>

%T

</TD><TD>

Local time

</TD></TR>



<TR><TD>

%F

</TD><TD>

Free space in the partition where

&lt;dir&gt; is located

</TD></TR>



<TR><TD>

%C

</TD><TD>

Current working directory

</TD></TR>



<TR><TD>

%E

</TD><TD>

Site maintainer's e-mail address (specified by the

email command)

</TD></TR>

</TABLE>



<A NAME="PAGENUM-141"><P>Page 141</P></A>





<HR>





<TABLE WIDTH="360">



<TR><TD>

Option

</TD><TD>

Description

</TD></TR>





<TR><TD>

%R

</TD><TD>

Client hostname

</TD></TR>



<TR><TD>

%L

</TD><TD>

Server hostname

</TD></TR>





<TR><TD>

%U

</TD><TD>

Username provided at login time

</TD></TR>



<TR><TD>

%M

</TD><TD>

Maximum number of users allowed in the specified class

</TD></TR>





<TR><TD>

%N

</TD><TD>

Current number of users in specified class

</TD></TR>

</TABLE>





<P>Remember that when messages are triggered by an anonymous user, the message path needs

to be relative to the anonymous FTP directory.

</P>









<P>An example message command is

</P>





<!-- CODE SNIP //-->

<PRE>

message ./.toomany_anon LOGIN anonfolks

</PRE>

<!-- END CODE SNIP //-->











<P>where the file ./.toomany_anon contains

</P>





<!-- CODE SNIP //-->

<PRE>

Sorry %R, but there are already %N users out of a maximum of %M users in

&Acirc;your class.  Please try again in a few minutes.

The FTP Administrator (%E)

</PRE>

<!-- END CODE SNIP //-->











<P>If the limit of 25 users is reached at this site, for example, the client sees a message similar to

the following:

</P>





<!-- CODE //-->

<PRE>

Sorry, technics.domain.com, but there are already 25 out of a maximum

&Acirc;of 25 users in your class. Please try again in a few minutes.

The FTP Administrator (ftp@domain.com)

</PRE>

<!-- END CODE //-->











<H5><A NAME="ch08_ 18">

readme

</A></H5>









<P>The readme command allows you to specify the conditions under which clients are

notified that a certain file in their current directory was last modified. This command can take the form

</P>





<!-- CODE SNIP //-->

<PRE>

readme &lt;path&gt; &lt;when&gt; &lt;class&gt;

</PRE>

<!-- END CODE SNIP //-->











<P>where &lt;path&gt; is the name of the file to alert the clients about (for example,

README), &lt;when&gt; is similar to the

&lt;when&gt; in the message command, and

&lt;class&gt; is the classes for which this command applies. The

&lt;when&gt; and &lt;class&gt; parameters are optional.

</P>









<P>Remember that when you're specifying a path for anonymous users, the file must be relative

to the anonymous FTP directory.

</P>









<H4><A NAME="ch08_ 19">





Controlling Logging

</A></H4>









<P>As with any complex network service, security quickly becomes an issue. In order to

contend with possible threats, tracking connections made along with the corresponding commands is

a necessity. The following commands allow you to determine how much, if any,

logging should be done by the server software.

</P>





<P><CENTER>

<a href="0135-0138.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0142-0144.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?