FTPD(8)                 NetBSD System Manager's Manual                 FTPD(8)

NNAAMMEE
     ffttppdd, ffttppdd..ccoonnff - Internet File Transfer Protocol server

SSYYNNOOPPSSIISS
     ffttppdd [--ddll] [--aa _a_n_o_n_d_i_r] [--cc _c_o_n_f_d_i_r] [--CC _u_s_e_r]

DDEESSCCRRIIPPTTIIOONN
     ffttppdd 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a      Define the directory to chroot(2) into for anonymous logins.  De-
             fault is the home directory for the ftp user.

     --cc      Change the root directory of the configuration files from
             ``_/_e_t_c'' to _d_i_r_e_c_t_o_r_y.

     --CC      Check whether the specified user would be granted access under
             the restrictions given in _/_e_t_c_/_f_t_p_u_s_e_r_s and exit without attempt-
             ing a connection.  ffttppdd exits with an exit code of 0 if access
             would be granted, or 1 otherwise.  This can be useful for testing
             configurations.

     --dd      Debugging information is written to the syslog using LOG_FTP.

     --l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.

     The file _/_e_t_c_/_n_o_l_o_g_i_n can be used to disable ftp access.  If the file ex-
     ists, ffttppdd displays it and exits.  If the file _/_e_t_c_/_f_t_p_w_e_l_c_o_m_e exists,
     ffttppdd prints it before issuing the ``ready'' message.  If the file
     _/_e_t_c_/_m_o_t_d exists, ffttppdd 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
           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 _m_o_d_e
           NLST       give name list of files in directory
           NOOP       do nothing
           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 _s_t_r_u_c_t_u_r_e
           SYST       show operating system type of server system
           TYPE       specify data transfer _t_y_p_e
           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.

           RReeqquueesstt    DDeessccrriippttiioonn
           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 remaining ftp requests specified in Internet RFC 959 are recognized,
     but not implemented.  MDTM and SIZE are not specified 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.

     ffttppdd interprets file names according to the ``globbing'' conventions used
     by csh(1).  This allows users to utilize the metacharacters ``*?[]{}~''.

   UUsseerr aauutthheennttiiccaattiioonn
     ffttppdd authenticates users according to five rules.

           1.   The login name must be in the password data base, _/_e_t_c_/_p_w_d_._d_b,
                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
                _/_e_t_c_/_f_t_p_u_s_e_r_s (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 _/_b_i_n_/_s_h.)

           4.   If the user name appears in the file _/_e_t_c_/_f_t_p_c_h_r_o_o_t 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
                _/_e_t_c_/_f_t_p_d_._c_o_n_f are required.

   //eettcc//ffttppuusseerrss
     The file _/_e_t_c_/_f_t_p_u_s_e_r_s 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 a comment starting with ``#'' or a glob pattern that uses
     the same syntax as /bin/sh, optionally followed by whitespace and
     ``allow'' or ``deny''. Each glob pattern is compared in turn against the
     username until a match is found.  If the word following the matched glob
     pattern is ``allow'' the user is granted access; if the word is anything
     else, or nothing at all, the user is denied access.  (No further compar-
     isons are attempted after the first successful match.)  If no match is
     found, the user is granted access.  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
     _/_e_t_c_/_f_t_p_u_s_e_r_s in order to allow guest logins.

   //eettcc//ffttppdd..ccoonnff
     The file _/_e_t_c_/_f_t_p_d_._c_o_n_f 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:

     cchheecckkppoorrttccmmdd _c_l_a_s_s [ooffff]
           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 _s_t_r_o_n_g_l_y encouraged that this option be used, espcially for
           sites concerned with potential security problems with ftp bounce
           attacks.  If class is ``none'' or ooffff is given, disable this fea-
           ture, otherwise enable it.

     ccoonnvveerrssiioonn _c_l_a_s_s _s_u_f_f_i_x [_t_y_p_e _d_i_s_a_b_l_e _c_o_m_m_a_n_d]
           Define an automatic in-line file conversion.  If a file to retrieve
           ends in _s_u_f_f_i_x, and a real file (sans _s_u_f_f_i_x) exists, then the out-
           put of _c_o_m_m_a_n_d is returned instead of the contents of the file.

                 _s_u_f_f_i_x   The suffix to initiate the conversion.

                 _t_y_p_e     A list of valid filetypes for the conversion.  Valid
                          types are: `f' (file), and `d' (directory).

                 _d_i_s_a_b_l_e  The name of file that will prevent conversion if it
                          exists.  A filename of _. will prevent this disabling
                          action.

                 _c_o_m_m_a_n_d  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 _c_o_m_m_a_n_d is replaced with the re-
                          quested file (sans _s_u_f_f_i_x).

           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).

     ddiissppllaayy _c_l_a_s_s [_f_i_l_e]
           If _f_i_l_e isn't given or _c_l_a_s_s is ``none'', disable this.  Otherwise,
           each time the user enters a new directory, check if _f_i_l_e exists,
           and if so, display its contents to the user.

     mmaaxxttiimmeeoouutt _c_l_a_s_s _t_i_m_e
           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 ttiimmeeoouutt. Ignored if class is ``none'' or _t_i_m_e isn't spec-
           ified.

     mmooddiiffyy _c_l_a_s_s [ooffff]
           If class is ``none'' or ooffff is given, disable the following com-
           mands: CHMOD, DELE, MKD, RNFR, RMD, and UMASK.  Otherwise, enable
           them.

     nnoottiiffyy _c_l_a_s_s [_f_i_l_e_g_l_o_b]
           If _f_i_l_e_g_l_o_b isn't given or _c_l_a_s_s is ``none'', disable this.  Other-
           wise, each time the user enters a new directory, notify the user of
           any files matching _f_i_l_e_g_l_o_b.

     ttiimmeeoouutt _c_l_a_s_s _t_i_m_e
           Set the inactivity timeout period.  (the default is fifteen min-
           utes).  This cannot be lesser than 30 seconds, or greater than the
           value for mmaaxxttiimmeeoouutt. Ignored if class is ``none'' or _t_i_m_e isn't
           specified.

     uummaasskk _c_l_a_s_s _u_m_a_s_k_v_a_l
           Set the umask to _u_m_a_s_k_v_a_l. Ignored if class is ``none'' or _u_m_a_s_k_v_a_l
           isn't specified.

     In any configuration line, _c_l_a_s_s is one of:
           rreeaall    Normal user logins.
           cchhrroooott  Users that have been chroot(2)ed.
           gguueesstt   ``anonymous'' and ``ftp'' users.
           aallll     Matches any class.
           nnoonnee    Matches no class.

     The following defaults are used:
           checkportcmd  none
           display       none
           maxtimeout    all    7200   # 2 hours
           modify        all
           modify        guest  off
           notify        none
           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 _/_e_t_c_/_f_t_p_d_._c_o_n_f.


   SSeettttiinngg uupp aa rreessttrriicctteedd ffttpp ssuubbttrreeee
     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):

           _~_f_t_p           Make the home directory owned by ``root'' and un-
                          writable by anyone.

           _~_f_t_p_/_b_i_n       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.

           _~_f_t_p_/_e_t_c       Make this directory owned by ``root'' and unwritable
                          by anyone (mode 555).  The files _p_w_d_._d_b (see
                          passwd(5))  and _g_r_o_u_p (see group(5))  must be pre-
                          sent for the ls command to be able to produce owner
                          names rather than numbers.  The password field in
                          passwd is not used, and should not contain real
                          passwords.  The file _m_o_t_d, if present, will be
                          printed after a successful login.  These files
                          should be mode 444.

           _~_f_t_p_/_p_u_b       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 _n_o_t be owned or
                          writable by ftp or its group.

           _~_f_t_p_/_i_n_c_o_m_i_n_g  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.

FFIILLEESS
     /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.

SSEEEE AALLSSOO
     ftp(1),  skey(1),  getusershell(3),  syslogd(8)

BBUUGGSS
     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.  The
     possible security holes have been extensively scrutinized, but are possi-
     bly incomplete.

     RRFFCC--995599 provides no restrictions on the PORT command, and this can lead
     to security problems, as ffttppdd can be fooled into connecting to any ser-
     vice on any host.  With the ``checkportcmd'' feature of the
     _/_e_t_c_/_f_t_p_d_._c_o_n_f, PORT commands with different host addresses, or TCP ports
     lower than IPPORT_RESERVED will be rejected.  Use of this option is
     _s_t_r_o_n_g_l_y recommended.

     The feedback to the client is inadequate in the case of an error that oc-
     curs during a retrieval that uses a ``conversion'' command (refer to
     _/_e_t_c_/_f_t_p_d_._c_o_n_f).

HHIISSTTOORRYY
     The ffttppdd command appeared in 4.2BSD.

     The _/_e_t_c_/_f_t_p_d_._c_o_n_f functionality was implemented in NetBSD 1.3 by Luke
     Mewburn, based on work by Simon Burge.

NetBSD                           June 10, 1997                               6
