Examples
Several conversion rules may be specified in wu-ftpd
's default ftpconversions
file. Additional examples of conversion rules, such as for Sun's Solaris operating system, might be available in the wu-ftpd
documentation.
Using ftphosts
to Allow or Deny FTP Server Connection
The purpose of the ftphosts
file is to allow or deny specific users or addresses from connecting to the FTP server. The format of the file is the word allow
or deny
, optionally followed by a username, followed by an IP or a DNS address.
allow username address
deny username address
Listing 20.3 shows a sample configuration of this file.
LISTING 20.3 ftphosts
Configuration File for Allowing or Denying Users
# Example host access file
#
# Everything after a '#' is treated as comment,
# empty lines are ignored
allow tdc 128.0.0.1
allow tdc 192.168.101.*
allow tdc insanepenguin.net
allow tdc *.exodous.net
deny anonymous 201.*
deny anonymous *.pilot.net
The *
is a wildcard that matches any combination of that address. For example, allow tdc *.exodous.net
allows the user tdc
to log in to the FTP server from any address that contains the domain name exodous.net. Similarly, the anonymous user is not allowed to access the FTP if he is coming from a 201 public class C IP address.
Changes made to your system's FTP server configuration files become active only after you restart xinetd
because configuration files are parsed only at startup. To restart xinetd
as root, issue the command /etc/rc.d/init.d/xinetd restart
. This makes a call to the same shell script that is called at system startup and shutdown for any runlevel to start or stop the xinet
daemon. xinetd
should report its status as:
# /etc/rc.d/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
When the FTP server restarts, it is accessible to all incoming requests.
Using Commands for Server Administration
wu-ftp provides a few commands to aid in server administration. Those commands are:
► ftpwho
— Displays information about current FTP server users
► ftpcount
— Displays information about current server users by class
► ftpshut
— Provides automated server shutdown and user notification
► ftprestart
— Provides automated server restart and shutdown message removal
Each of these commands must be executed with superuser privileges because they reference the ftpaccess
configuration file to obtain information about the FTP server.
Display Information About Connected Users
The ftpwho command provides information about the users currently connected to the FTP server. Here's the command line:
/usr/bin/ftpwho
Table 20.3 shows the format of the output ftpwho
displays.
TABLE 20.3 ftpwho
Fields
Name |
Description |
Process ID |
The process ID of the FTP server process. |
TTY |
The terminal ID of the process. This is always a question mark ( ? ) because the FTP daemon is not an interactive login. |
Status |
The status of the FTP process. The values are: |
S : Sleeping |
Z : Zombie, indicating a crash |
R : Running |
N : Normal process |
Time |
The elapsed processor time the process has used in minutes and seconds. |
Details |
Tells from what host the process is connecting, the user who connected, and the currently executing command. |
Listing 20.4 shows typical output from this command. It lists the process ID for the ftp
daemon handling requests, the class to which the particular user belongs, the total time connected, the connected username, and the status of the session.
In addition to the information given about each connected user, ftpwho
also displays the total number of users connected out of any maximum that has been set in the ftpaccess
file. This information can be used to monitor the use of your FTP server.
You can pass one parameter to ftpwho
. (You can find the parameter by using the ftpwho --help
command.) The single parameter you can pass to ftpwho
is -V
. This parameter prints out version and licensing information for wu-ftp
, as shown here:
# ftpwho
Service class all:
10447 ? SN 0:00 ftpd: localhost: anonymous/winky@disney.com: IDLE
1 users (no maximum)
The output of ftpwho
, using the -V
option, which shows version information, is shown in Listing 20.4.
LISTING 20.4 ftpwho -V
Command Output
Copyright © 1999,2000,2001 WU-FTPD Development Group.
All rights reserved.
Portions Copyright © 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
The Regents of the University of California.
Portions Copyright © 1993, 1994 Washington University in Saint Louis.
Portions Copyright © 1996, 1998 Berkeley Software Design, Inc.
Portions Copyright © 1989 Massachusetts Institute of Technology.
Portions Copyright © 1998 Sendmail, Inc.
Portions Copyright © 1983, 1995, 1996, 1997 Eric P. Allman.
Portions Copyright © 1997 by Stan Barber.
Portions Copyright © 1997 by Kent Landfield.
Portions Copyright © 1991, 1992, 1993, 1994, 1995, 1996, 1997
Free Software Foundation, Inc.
Use and distribution of this software and its source code are governed by
the terms and conditions of the WU-FTPD Software License ("LICENSE").
If you did not receive a copy of the license, it may be obtained online
at http://www.wu-ftpd.org/license.html.
Version wu-2.6.2-8
Count the Number of Connections
/usr/bin/ftpcount
counts the number of connected users to the FTP server and the maximum number of users allowed. This same information is found at the end of the output for the ftpwho
command. This command takes only one parameter, -V
, which displays the same output as the previous ftpwho
example.
# ftpcount
Service class all - 4 users (no maximum)
Use /usr/sbin/ftpshut
to Schedule FTP Server Downtime
As with any public server administration, it is always good practice to let users of the FTP server know about upcoming outages, when the server will be updated, and other relevant site information. The ftpshut
command allows the administrator to let the FTP server do much of this automatically.
The ftpshut
command enables the administrator to take down the FTP server at a specific time, based on some parameters passed to it. The format of the command is as follows and is documented in the ftpshut
man page:
Читать дальше