FTPD(8) NetBSD System Manager's Manual FTPD(8)
NAME
ftpd, ftpd.conf - Internet File Transfer Protocol server
SYNOPSIS
ftpd [-dls] [-a anondir] [-c confdir] [-C user]
DESCRIPTION
ftpd is the Internet File Transfer Protocol server process. The server uses the TCP protocol and listens at the port specified in the ``ftp'' service specification; see services(5). Available options: -a Define the directory to chroot(2) into for anonymous logins. De- fault is the home directory for the ftp user. -c Change the root directory of the configuration files from ``/etc'' to directory. -C Check whether the specified user would be granted access under the restrictions given in /etc/ftpusers and exit without attempt- ing a connection. ftpd exits with an exit code of 0 if access would be granted, or 1 otherwise. This can be useful for testing configurations. -d Debugging information is written to the syslog using LOG_FTP. -l Each successful and failed ftp(1) session is logged using syslog with a facility of LOG_FTP. If this option is specified twice, the retrieve (get), store (put), append, delete, make directory, remove directory and rename operations and their filename argu- ments are also logged. -s Require a secure authentication mechanism like Kerberos or S/Key to be used. The file /etc/nologin can be used to disable ftp access. If the file ex- ists, ftpd displays it and exits. If the file /etc/ftpwelcome exists, ftpd prints it before issuing the ``ready'' message. If the file /etc/motd exists, ftpd prints it after a successful login. The ftp server currently supports the following ftp requests. The case of the requests is ignored. Request Description ABOR abort previous command ACCT specify account (ignored) ALLO allocate storage (vacuously) APPE append to a file CDUP change to parent of current working directory CWD change working directory DELE delete a file FEAT list extra features that are not defined in RFC 959 HELP give help information LIST give list files in a directory (``ls -lgA'') MKD make a directory MDTM show last modification time of file MODE specify data transfer mode NLST give name list of files in directory NOOP do nothing OPTS define persistent options for a given command PASS specify password PASV prepare for server-to-server transfer PORT specify data connection port PWD print the current working directory QUIT terminate session REST restart incomplete transfer RETR retrieve a file RMD remove a directory RNFR specify rename-from file name RNTO specify rename-to file name SITE non-standard commands (see next section) SIZE return size of file STAT return status of server STOR store a file STOU store a file with a unique name STRU specify data transfer structure SYST show operating system type of server system TYPE specify data transfer type USER specify user name XCUP change to parent of current working directory (deprecated) XCWD change working directory (deprecated) XMKD make a directory (deprecated) XPWD print the current working directory (deprecated) XRMD remove a directory (deprecated) The following non-standard or UNIX specific commands are supported by the SITE request. Request Description CHMOD change mode of a file, e.g. ``SITE CHMOD 755 filename'' HELP give help information. IDLE set idle-timer, e.g. ``SITE IDLE 60'' UMASK change umask, e.g. ``SITE UMASK 002'' The following ftp requests (as specified in RFC 959) are recognized, but are not implemented: ACCT, SMNT, and REIN. MDTM and SIZE are not speci- fied in RFC 959, but will appear in the next updated FTP RFC. The ftp server will abort an active file transfer only when the ABOR com- mand is preceded by a Telnet "Interrupt Process" (IP) signal and a Telnet "Synch" signal in the command Telnet stream, as described in Internet RFC 959. If a STAT command is received during a data transfer, preceded by a Telnet IP and Synch, transfer status will be returned. ftpd interprets file names according to the ``globbing'' conventions used by csh(1). This allows users to utilize the metacharacters ``*?[]{}~''. User authentication ftpd authenticates users according to five rules. 1. The login name must be in the password data base, /etc/pwd.db, and not have a null password. In this case a password must be provided by the client before any file operations may be per- formed. If the user has an S/Key key, the response from a successful USER command will include an S/Key challenge. The client may choose to respond with a PASS command giving either a standard password or an S/Key one-time password. The server will automatically determine which type of password it has been given and attempt to authenticate accordingly. See skey(1) for more information on S/Key authentication. S/Key is a Trademark of Bellcore. 2. The login name must be allowed based on the information in /etc/ftpusers (see below). 3. The user must have a standard shell returned by getusershell(3). If the user's shell field in the password database is empty, the shell is assumed to be /bin/sh. 4. If directed by the file /etc/ftpchroot (see below) the ses- sion's root will be changed to the user's login directory by chroot(2) as for an ``anonymous'' or ``ftp'' account (see next item). However, the user must still supply a password. This feature is intended as a compromise between a fully anonymous account and a fully privileged account. The account should also be set up as for an anonymous account. 5. If the user name is ``anonymous'' or ``ftp'', an anonymous ftp account must be present in the password file (user ``ftp''). In this case the user is allowed to log in by specifying any password (by convention an email address for the user should be used as the password). The server performs a chroot(2) to the home directory of the ``ftp'' user. If other restrictions are required (such as disabling of certain commands and the setting of a specific umask), then appropriate entries in /etc/ftpd.conf are required. /etc/ftpusers The file /etc/ftpusers is used to determine which users may use ftp. If the file does not exist, all users are denied access. If it does exist, each line is a comment starting with ``#'' or a glob pattern that uses the same syntax as /bin/sh, optionally followed by whitespace and ``allow'', ``yes'', ``deny'', or ``no''. Each glob pattern is compared in turn against the username until a match is found. If the word follow- ing the matched glob pattern is ``allow'' or ``yes'' the user is granted access; if the word is ``deny'' or ``no'', or if the word is missing, the user is denied access. No further comparisons are attempted after the first successful match. If no match is found, the user is granted ac- cess. This syntax is backward-compatable with the old syntax. If a user requests a guest login, the ftp server checks to see that both ``anonymous'' and ``ftp'' have access, so if you deny all users by de- fault, you will need to add both ``anonymous allow'' and ``ftp allow'' to /etc/ftpusers in order to allow guest logins. /etc/ftpchroot The file /etc/ftpchroot is used to determine which users will have their session's root changed to the user's home directory. If the file does not exist, the root change is not performed. If it does exist, each line is a comment starting with ``#'' or a glob pattern that uses the same syntax as /bin/sh, optionally followed by whitespace and ``yes'' or ``no''. Each glob pattern is compared in turn against the username until a match is found. If the word following the matched glob pattern is ``yes'' or there is no following word, the root is changed. If the word is ``no'', or if no match is found, the root is not changed. No further comparisons are attempted after the first successful match. This syntax is backward-compatable with the old syntax. /etc/ftpd.conf The file /etc/ftpd.conf is used to configure various options. Each line starting with a ``#'' is a comment (and ignored), and all other non-blank lines are treated as configuration directives. Each configuration line may be one of: checkportcmd class [off] Check the PORT command for validity. The PORT command will fail if the IP address specified does not match the ftp command connection, or if the remote TCP port number is less than IPPORT_RESERVED. It is strongly encouraged that this option be used, espcially for sites concerned with potential security problems with ftp bounce attacks. If class is ``none'' or off is given, disable this fea- ture, otherwise enable it. conversion class suffix [type disable command] Define an automatic in-line file conversion. If a file to retrieve ends in suffix, and a real file (sans suffix) exists, then the out- put of command is returned instead of the contents of the file. suffix The suffix to initiate the conversion. type A list of valid filetypes for the conversion. Valid types are: `f' (file), and `d' (directory). disable The name of file that will prevent conversion if it exists. A filename of . will prevent this dis- abling action. command The command to run for the conversion. The first word should be the full path name of the command, as execv(3) is used to execute the command. The first instance of `%s' in command is replaced with the re- quested file (sans suffix). Conversion directives specified later in the file override earlier conversions with the same suffix. The order in which conversions is matched is the reverse of their order in the file (i.e. a LIFO). display class [file] If file isn't given or class is ``none'', disable this. Otherwise, each time the user enters a new directory, check if file exists, and if so, display its contents to the user. maxtimeout class time Set the maximum timeout period that a client may request, default- ing to two hours. This cannot be lesser than 30 seconds, or the value for timeout. Ignored if class is ``none'' or time isn't specified. modify class [off] If class is ``none'' or off is given, disable the following com- mands: CHMOD, DELE, MKD, RNFR, RMD, and UMASK. Otherwise, enable them. notify class [fileglob] If fileglob isn't given or class is ``none'', disable this. Other- wise, each time the user enters a new directory, notify the user of any files matching fileglob. passive class [off] If class is ``none'' or off is given, disallow passive (PASV) con- nections. Otherwise, enable them. timeout class time Set the inactivity timeout period. (the default is fifteen min- utes). This cannot be lesser than 30 seconds, or greater than the value for maxtimeout. Ignored if class is ``none'' or time isn't specified. umask class umaskval Set the umask to umaskval. Ignored if class is ``none'' or umaskval isn't specified. In any configuration line, class is one of: real Normal user logins. chroot Users that have been chroot(2)ed. guest ``anonymous'' and ``ftp'' users. all Matches any class. none Matches no class. The following defaults are used: checkportcmd none display none maxtimeout all 7200 # 2 hours modify all modify guest off notify none passive all timeout all 900 # 15 minutes umask all 027 umask guest 0707 Directives that appear later in the file override settings by previous directives. This allows `wildcard' entries to define defaults, and then have class-specific overrides. The STAT command will return the class settings for the current user as defined by /etc/ftpd.conf. Setting up a restricted ftp subtree In order that system security is not breached, it is recommended that the subtrees for the ``ftp'' and ``chroot'' accounts be constructed with care, following these rules (replace ``ftp'' in the following directory names with the appropriate account name for `chroot' users): ~ftp Make the home directory owned by ``root'' and un- writable by anyone. ~ftp/bin Make this directory owned by ``root'' and unwritable by anyone (mode 555). The program ls(1) must be present to support the `LIST' command. This program should be mode 111. ~ftp/etc Make this directory owned by ``root'' and unwritable by anyone (mode 555). The files pwd.db (see passwd(5)) and group (see group(5)) must be present for the ls(1) command to be able to produce owner names rather than numbers. The password field in passwd(5) is not used, and should not contain real passwords. The file motd, if present, will be printed after a successful login. These files should be mode 444. ~ftp/pub This directory and the subdirectories beneath it should be owned by the users and groups responsible for placing files in them, and be writable only by them (mode 755 or 775). They should not be owned or writable by ftp or its group. ~ftp/incoming This directory is where anonymous users place files they upload. The owners should be the user ``ftp'' and an appropriate group. Members of this group will be the only users with access to these files after they have been uploaded; these should be peo- ple who know how to deal with them appropriately. If you wish anonymous ftp users to be able to see the names of the files in this directory the permis- sions should be 770, otherwise they should be 370. Anonymous users will be able to upload files to this directory, but they will not be able to download them, delete them, or overwrite them, due to the umask and disabling of the commands mentioned above. ~ftp/tmp This directory is used to create temporary files which contain the error messages generated by a con- version or `LIST' command. The owner should be the user ``ftp''. The permissions should be 300. If you don't enable conversion commands, or don't want anonymous users uploading files (see ~ftp/incoming above), then don't create this direc- tory. However, error messages from conversion or `LIST' commands won't be returned to the user. (This is the traditional behaviour.)
FILES
/etc/ftpchroot List of normal users who should be chroot'd. /etc/ftpd.conf Configure file conversions and other settings. /etc/ftpusers List of unwelcome/restricted users. /etc/ftpwelcome Welcome notice before login. /etc/motd Welcome notice after login. /etc/nologin If it exists, displayed and access is refused.
SEE ALSO
ftp(1), skey(1), getusershell(3), syslogd(8)
STANDARDS
ftpd recognizes all commands in RFC 959, follows the guidelines in RFC 1123, recognizes all commands in RFC 2228 (although they are not support- ed yet), and supports the extensions from RFC 2389.
HISTORY
The ftpd command appeared in 4.2BSD. The /etc/ftpd.conf functionality was implemented in NetBSD 1.3 by Luke Mewburn, based on work by Simon Burge.
BUGS
The server must run as the super-user to create sockets with privileged port numbers. It maintains an effective user id of the logged in user, reverting to the super-user only when binding addresses to sockets.
SECURITY CONSIDERATIONS
RFC 959 provides no restrictions on the PORT command, and this can lead to security problems, as ftpd can be fooled into connecting to any ser- vice on any host. With the ``checkportcmd'' feature of the /etc/ftpd.conf, PORT commands with different host addresses, or TCP ports lower than IPPORT_RESERVED will be rejected. Use of this option is strongly recommended. NetBSD 1.4 September 7, 1998 6
Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.