1.\" Copyright (c) 1985, 1988, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94 33.\" $FreeBSD$ 34.\" 35.Dd April 19, 1994 36.Dt FTPD 8 37.Os BSD 4.2 38.Sh NAME 39.Nm ftpd 40.Nd 41Internet File Transfer Protocol server 42.Sh SYNOPSIS 43.Nm ftpd 44.Op Fl d 45.Op Fl l Op Fl l 46.Op Fl A 47.Op Fl D 48.Op Fl R 49.Op Fl S 50.Op Fl U 51.Op Fl T Ar maxtimeout 52.Op Fl t Ar timeout 53.Op Fl a Ar address 54.Op Fl p Ar file 55.Sh DESCRIPTION 56.Nm Ftpd 57is the 58Internet File Transfer Protocol 59server process. The server uses the 60.Tn TCP 61protocol 62and listens at the port specified in the 63.Dq ftp 64service specification; see 65.Xr services 5 . 66.Pp 67Available options: 68.Bl -tag -width indent 69.It Fl d 70Debugging information is written to the syslog using LOG_FTP. 71.It Fl l 72Each successful and failed 73.Xr ftp 1 74session is logged using syslog with a facility of LOG_FTP. 75If this option is specified twice, the retrieve (get), store (put), append, 76delete, make directory, remove directory and rename operations and 77their filename arguments are also logged. Note: LOG_FTP messages 78are not displayed by 79.Xr syslogd 8 80by default, and may have to be enabled in 81.Xr syslogd 8 Ns 's 82configuration file. 83.It Fl D 84With this option set, 85.Nm 86will detach and become a daemon, accepting connections on the FTP port and 87forking children processes to handle them. This is lower overhead than 88starting 89.Nm 90from 91.Xr inetd 8 92and is thus useful on busy servers to reduce load. 93.It Fl R 94With this option set, 95.Nm 96will revert to historical behavior with regard to security checks on 97user operations and restrictions on PORT requests. 98Currently, 99.Nm 100will only honor PORT commands directed to unprivileged ports on the 101remote user's host (which violates the FTP protocol specification but 102closes some security holes). 103.It Fl S 104With this option set, 105.Nm 106logs all anonymous transfers to the file 107.Pa /var/log/ftpd 108when this file exists. 109.It Fl U 110In previous versions of 111.Nm Ns , 112when a passive mode client requested a data connection to the server, 113the server would use data ports in the range 1024..4999. Now, by default, 114the server will use data ports in the range 49152..65535. Specifying this 115option will revert to the old behavior. 116.It Fl T 117A client may also request a different timeout period; 118the maximum period allowed may be set to 119.Ar timeout 120seconds with the 121.Fl T 122option. 123The default limit is 2 hours. 124.It Fl t 125The inactivity timeout period is set to 126.Ar timeout 127seconds (the default is 15 minutes). 128.It Fl a 129When 130.Fl D 131is specified, accept connections only on the specified 132.Ar address . 133.It Fl p 134When 135.Fl D 136is specified, write the daemon's process ID to 137.Ar file . 138.It Fl A 139Allow only anonymous ftp access. 140.El 141.Pp 142The file 143.Pa /var/run/nologin 144can be used to disable ftp access. 145If the file exists, 146.Nm 147displays it and exits. 148If the file 149.Pa /etc/ftpwelcome 150exists, 151.Nm 152prints it before issuing the 153.Dq ready 154message. 155If the file 156.Pa /etc/ftpmotd 157exists, 158.Nm 159prints it after a successful login. Note the motd file used is the one 160relative to the login environment. This means the one in 161.Pa ~ftp/etc 162in the anonymous user's case. 163.Pp 164The ftp server currently supports the following ftp requests. 165The case of the requests is ignored. 166.Bl -column "Request" -offset indent 167.It Sy Request Ta Sy "Description" 168.It ABOR Ta "abort previous command" 169.It ACCT Ta "specify account (ignored)" 170.It ALLO Ta "allocate storage (vacuously)" 171.It APPE Ta "append to a file" 172.It CDUP Ta "change to parent of current working directory" 173.It CWD Ta "change working directory" 174.It DELE Ta "delete a file" 175.It HELP Ta "give help information" 176.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" 177.It MKD Ta "make a directory" 178.It MDTM Ta "show last modification time of file" 179.It MODE Ta "specify data transfer" Em mode 180.It NLST Ta "give name list of files in directory" 181.It NOOP Ta "do nothing" 182.It PASS Ta "specify password" 183.It PASV Ta "prepare for server-to-server transfer" 184.It PORT Ta "specify data connection port" 185.It PWD Ta "print the current working directory" 186.It QUIT Ta "terminate session" 187.It REST Ta "restart incomplete transfer" 188.It RETR Ta "retrieve a file" 189.It RMD Ta "remove a directory" 190.It RNFR Ta "specify rename-from file name" 191.It RNTO Ta "specify rename-to file name" 192.It SITE Ta "non-standard commands (see next section)" 193.It SIZE Ta "return size of file" 194.It STAT Ta "return status of server" 195.It STOR Ta "store a file" 196.It STOU Ta "store a file with a unique name" 197.It STRU Ta "specify data transfer" Em structure 198.It SYST Ta "show operating system type of server system" 199.It TYPE Ta "specify data transfer" Em type 200.It USER Ta "specify user name" 201.It XCUP Ta "change to parent of current working directory (deprecated)" 202.It XCWD Ta "change working directory (deprecated)" 203.It XMKD Ta "make a directory (deprecated)" 204.It XPWD Ta "print the current working directory (deprecated)" 205.It XRMD Ta "remove a directory (deprecated)" 206.El 207.Pp 208The following non-standard or 209.Tn UNIX 210specific commands are supported 211by the 212SITE request. 213.Pp 214.Bl -column Request -offset indent 215.It Sy Request Ta Sy Description 216.It UMASK Ta change umask, e.g. ``SITE UMASK 002'' 217.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60'' 218.It CHMOD Ta "change mode of a file, e.g. ``SITE CHMOD 755 filename''" 219.It HELP Ta give help information 220.El 221.Pp 222The remaining ftp requests specified in Internet RFC 959 223are 224recognized, but not implemented. 225MDTM and SIZE are not specified in RFC 959, but will appear in the 226next updated FTP RFC. 227.Pp 228The ftp server will abort an active file transfer only when the 229ABOR 230command is preceded by a Telnet "Interrupt Process" (IP) 231signal and a Telnet "Synch" signal in the command Telnet stream, 232as described in Internet RFC 959. 233If a 234STAT 235command is received during a data transfer, preceded by a Telnet IP 236and Synch, transfer status will be returned. 237.Pp 238.Nm Ftpd 239interprets file names according to the 240.Dq globbing 241conventions used by 242.Xr csh 1 . 243This allows users to utilize the metacharacters 244.Dq Li \&*?[]{}~ . 245.Pp 246.Nm Ftpd 247authenticates users according to five rules. 248.Pp 249.Bl -enum -offset indent 250.It 251The login name must be in the password data base 252and not have a null password. 253In this case a password must be provided by the client before any 254file operations may be performed. 255If the user has an S/Key key, the response from a successful USER 256command will include an S/Key challenge. The client may choose to respond 257with a PASS command giving either a standard password or an S/Key 258one-time password. The server will automatically determine which type of 259password it has been given and attempt to authenticate accordingly. See 260.Xr key 1 261for more information on S/Key authentication. S/Key is a Trademark of 262Bellcore. 263.It 264The login name must not appear in the file 265.Pa /etc/ftpusers . 266.It 267The login name must not be a member of a group specified in the file 268.Pa /etc/ftpusers . 269Entries in this file interpreted as group names are prefixed by an "at" 270.Ql \&@ 271sign. 272.It 273The user must have a standard shell returned by 274.Xr getusershell 3 . 275.It 276If the user name appears in the file 277.Pa /etc/ftpchroot , 278or the user is a member of a group with a group entry in this file, 279i.e. one prefixed with 280.Ql \&@ , 281the session's root will be changed to the user's login directory by 282.Xr chroot 2 283as for an 284.Dq anonymous 285or 286.Dq ftp 287account (see next item). 288This facility may also be triggered by enabling the boolean "ftp-chroot" 289capability in 290.Xr login.conf 5 . 291However, the user must still supply a password. 292This feature is intended as a compromise between a fully anonymous 293account and a fully privileged account. 294The account should also be set up as for an anonymous account. 295.It 296If the user name is 297.Dq anonymous 298or 299.Dq ftp , 300an 301anonymous ftp account must be present in the password 302file (user 303.Dq ftp ) . 304In this case the user is allowed 305to log in by specifying any password (by convention an email address for 306the user should be used as the password). 307When the 308.Fl S 309option is set, all transfers are logged as well. 310.El 311.Pp 312In the last case, 313.Nm 314takes special measures to restrict the client's access privileges. 315The server performs a 316.Xr chroot 2 317to the home directory of the 318.Dq ftp 319user. 320In order that system security is not breached, it is recommended 321that the 322.Dq ftp 323subtree be constructed with care, following these rules: 324.Bl -tag -width "~ftp/pub" -offset indent 325.It Pa ~ftp 326Make the home directory owned by 327.Dq root 328and unwritable by anyone. 329.It Pa ~ftp/bin 330Make this directory owned by 331.Dq root 332and unwritable by anyone (mode 555). 333The program 334.Xr ls 1 335must be present to support the list command. 336This program should be mode 111. 337.It Pa ~ftp/etc 338Make this directory owned by 339.Dq root 340and unwritable by anyone (mode 555). 341The files pwd.db (see 342.Xr passwd 5 ) 343and 344.Xr group 5 345must be present for the 346.Xr ls 347command to be able to produce owner names rather than numbers. 348The password field in 349.Xr passwd 350is not used, and should not contain real passwords. 351The file 352.Pa ftpmotd , 353if present, will be printed after a successful login. 354These files should be mode 444. 355.It Pa ~ftp/pub 356Make this directory mode 777 and owned by 357.Dq ftp . 358Guests 359can then place files which are to be accessible via the anonymous 360account in this directory. 361.El 362.Pp 363If the system has multiple IP addresses, 364.Nm 365supports the idea of virtual hosts, which provides the ability to 366define multiple anonymous ftp areas, each one allocated to a different 367internet address. 368The file 369.Pa /etc/ftphosts 370contains information pertaining to each of the virtual hosts. 371Each host is defined on its own line which contains a number of 372fields separated by whitespace: 373.Bl -tag -offset indent -width hostname 374.It hostname 375Contains the hostname or IP address of the virtual host. 376.It user 377Contains a user record in the system password file. 378As with normal anonymous ftp, this user's access uid, gid and group 379memberships determine file access to the anonymous ftp area. 380The anonymous ftp area (to which any user is chrooted on login) 381is determined by the home directory defined for the account. 382User id and group for any ftp account may be the same as for the 383standard ftp user. 384.It statfile 385File to which all file transfers are logged, which 386defaults to 387.Pa /var/log/ftpd . 388.It welcome 389This file is the welcome message displayed before the server ready 390prompt. 391It defaults to 392.Pa /etc/ftpwelcome . 393.It motd 394This file is displayed after the user logs in. 395It defaults to 396.Pa /etc/ftpmotd . 397.El 398.Pp 399Lines beginning with a '#' are ignored and can be used to include 400comments. 401.Pp 402Defining a virtual host for the primary IP address or hostname 403changes the default for ftp logins to that address. 404The 'user', 'statfile', 'welcome' and 'motd' fields may be left 405blank, or a single hypen '-' used to indicate that the default 406value is to be used. 407.Pp 408As with any anonymous login configuration, due care must be given 409to setup and maintenance to guard against security related problems. 410.Pp 411.Nm 412has internal support for handling remote requests to list 413files, and will not execute 414.Pa /bin/ls 415in either a chrooted or non-chrooted environment. The 416.Pa ~/bin/ls 417executable need not be placed into the chrooted tree, nor need the 418.Pa ~/bin 419directory exist. 420.Sh FILES 421.Bl -tag -width /etc/ftpwelcome -compact 422.It Pa /etc/ftpusers 423List of unwelcome/restricted users. 424.It Pa /etc/ftpchroot 425List of normal users who should be chroot'd. 426.It Pa /etc/ftphosts 427Virtual hosting configuration file. 428.It Pa /etc/ftpwelcome 429Welcome notice. 430.It Pa /etc/ftpmotd 431Welcome notice after login. 432.It Pa /var/run/nologin 433Displayed and access refused. 434.It Pa /var/log/ftpd 435Log file for anonymous transfers. 436.El 437.Sh SEE ALSO 438.Xr ftp 1 , 439.Xr key 1 , 440.Xr getusershell 3 , 441.Xr login.conf 5 , 442.Xr inetd 8 , 443.Xr syslogd 8 444.Sh BUGS 445The server must run as the super-user 446to create sockets with privileged port numbers. It maintains 447an effective user id of the logged in user, reverting to 448the super-user only when binding addresses to sockets. The 449possible security holes have been extensively 450scrutinized, but are possibly incomplete. 451.Sh HISTORY 452The 453.Nm 454command appeared in 455.Bx 4.2 . 456