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.\" $Id: ftpd.8,v 1.17 1997/04/27 08:29:21 davidn Exp $ 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 dl 45.Op Fl D 46.Op Fl R 47.Op Fl S 48.Op Fl U 49.Op Fl T Ar maxtimeout 50.Op Fl t Ar timeout 51.Op Fl a Ar address 52.Op Fl p Ar file 53.Sh DESCRIPTION 54.Nm Ftpd 55is the 56Internet File Transfer Protocol 57server process. The server uses the 58.Tn TCP 59protocol 60and listens at the port specified in the 61.Dq ftp 62service specification; see 63.Xr services 5 . 64.Pp 65Available options: 66.Bl -tag -width Ds 67.It Fl d 68Debugging information is written to the syslog using LOG_FTP. 69.It Fl l 70Each successful and failed 71.Xr ftp 1 72session is logged using syslog with a facility of LOG_FTP. 73If this option is specified twice, the retrieve (get), store (put), append, 74delete, make directory, remove directory and rename operations and 75their filename arguments are also logged. Note: LOG_FTP messages 76are not displayed by 77.Xr syslogd 8 78by default, and may have to be enabled in 79.Xr syslogd 8 Ns 's 80configuration file. 81.It Fl D 82With this option set, 83.Nm ftpd 84will detach and become a daemon, accepting connections on the FTP port and 85forking children processes to handle them. This is lower overhead than 86starting 87.Nm ftpd 88from 89.Xr inetd 8 90and is thus useful on busy servers to reduce load. 91.It Fl R 92With this option set, 93.Nm ftpd 94will revert to historical behavior with regard to security checks on 95user operations and restrictions on PORT requests. 96Currently, 97.Nm ftpd 98will only honor PORT commands directed to unprivileged ports on the 99remote user's host (which violates the FTP protocol specification but 100closes some security holes). 101. 102.It Fl S 103With this option set, 104.Nm ftpd 105logs all anonymous transfers to the file 106.Pa /var/log/ftpd 107when this file exists. 108. 109.It Fl U 110In previous versions of 111.Nm ftpd , 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 40000..44999. 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 /etc/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. 160.Pp 161The ftp server currently supports the following ftp requests. 162The case of the requests is ignored. 163.Bl -column "Request" -offset indent 164.It Request Ta "Description" 165.It ABOR Ta "abort previous command" 166.It ACCT Ta "specify account (ignored)" 167.It ALLO Ta "allocate storage (vacuously)" 168.It APPE Ta "append to a file" 169.It CDUP Ta "change to parent of current working directory" 170.It CWD Ta "change working directory" 171.It DELE Ta "delete a file" 172.It HELP Ta "give help information" 173.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" 174.It MKD Ta "make a directory" 175.It MDTM Ta "show last modification time of file" 176.It MODE Ta "specify data transfer" Em mode 177.It NLST Ta "give name list of files in directory" 178.It NOOP Ta "do nothing" 179.It PASS Ta "specify password" 180.It PASV Ta "prepare for server-to-server transfer" 181.It PORT Ta "specify data connection port" 182.It PWD Ta "print the current working directory" 183.It QUIT Ta "terminate session" 184.It REST Ta "restart incomplete transfer" 185.It RETR Ta "retrieve a file" 186.It RMD Ta "remove a directory" 187.It RNFR Ta "specify rename-from file name" 188.It RNTO Ta "specify rename-to file name" 189.It SITE Ta "non-standard commands (see next section)" 190.It SIZE Ta "return size of file" 191.It STAT Ta "return status of server" 192.It STOR Ta "store a file" 193.It STOU Ta "store a file with a unique name" 194.It STRU Ta "specify data transfer" Em structure 195.It SYST Ta "show operating system type of server system" 196.It TYPE Ta "specify data transfer" Em type 197.It USER Ta "specify user name" 198.It XCUP Ta "change to parent of current working directory (deprecated)" 199.It XCWD Ta "change working directory (deprecated)" 200.It XMKD Ta "make a directory (deprecated)" 201.It XPWD Ta "print the current working directory (deprecated)" 202.It XRMD Ta "remove a directory (deprecated)" 203.El 204.Pp 205The following non-standard or 206.Tn UNIX 207specific commands are supported 208by the 209SITE request. 210.Pp 211.Bl -column Request -offset indent 212.It Sy Request Ta Sy Description 213.It UMASK Ta change umask, e.g. ``SITE UMASK 002'' 214.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60'' 215.It CHMOD Ta change mode of a file, e.g. ``SITE CHMOD 755 filename'' 216.It HELP Ta give help information. 217.El 218.Pp 219The remaining ftp requests specified in Internet RFC 959 220are 221recognized, but not implemented. 222MDTM and SIZE are not specified in RFC 959, but will appear in the 223next updated FTP RFC. 224.Pp 225The ftp server will abort an active file transfer only when the 226ABOR 227command is preceded by a Telnet "Interrupt Process" (IP) 228signal and a Telnet "Synch" signal in the command Telnet stream, 229as described in Internet RFC 959. 230If a 231STAT 232command is received during a data transfer, preceded by a Telnet IP 233and Synch, transfer status will be returned. 234.Pp 235.Nm Ftpd 236interprets file names according to the 237.Dq globbing 238conventions used by 239.Xr csh 1 . 240This allows users to utilize the metacharacters 241.Dq Li \&*?[]{}~ . 242.Pp 243.Nm Ftpd 244authenticates users according to five rules. 245.Pp 246.Bl -enum -offset indent 247.It 248The login name must be in the password data base 249and not have a null password. 250In this case a password must be provided by the client before any 251file operations may be performed. 252If the user has an S/Key key, the response from a successful USER 253command will include an S/Key challenge. The client may choose to respond 254with a PASS command giving either a standard password or an S/Key 255one-time password. The server will automatically determine which type of 256password it has been given and attempt to authenticate accordingly. See 257.Xr key 1 258for more information on S/Key authentication. S/Key is a Trademark of 259Bellcore. 260.It 261The login name must not appear in the file 262.Pa /etc/ftpusers . 263.It 264The login name must not be a member of a group specified in the file 265.Pa /etc/ftpusers . 266Entries in this file interpreted as group names are prefixed by an "at" 267.Ql \&@ 268sign. 269.It 270The user must have a standard shell returned by 271.Xr getusershell 3 . 272.It 273If the user name appears in the file 274.Pa /etc/ftpchroot , 275or the user is a member of a group with a group entry in this file, 276i.e. one prefixed with 277.Ql \&@ , 278the session's root will be changed to the user's login directory by 279.Xr chroot 2 280as for an 281.Dq anonymous 282or 283.Dq ftp 284account (see next item). 285This facility may also be triggered by enabling the boolean "ftp-chroot" 286capability in 287.Xr login.conf 5 . 288However, the user must still supply a password. 289This feature is intended as a compromise between a fully anonymous 290account and a fully privileged account. 291The account should also be set up as for an anonymous account. 292.It 293If the user name is 294.Dq anonymous 295or 296.Dq ftp , 297an 298anonymous ftp account must be present in the password 299file (user 300.Dq ftp ) . 301In this case the user is allowed 302to log in by specifying any password (by convention an email address for 303the user should be used as the password). 304When the 305.Fl S 306option is set, all transfers are logged as well. 307.El 308.Pp 309In the last case, 310.Nm ftpd 311takes special measures to restrict the client's access privileges. 312The server performs a 313.Xr chroot 2 314to the home directory of the 315.Dq ftp 316user. 317In order that system security is not breached, it is recommended 318that the 319.Dq ftp 320subtree be constructed with care, following these rules: 321.Bl -tag -width "~ftp/pub" -offset indent 322.It Pa ~ftp 323Make the home directory owned by 324.Dq root 325and unwritable by anyone. 326.It Pa ~ftp/bin 327Make this directory owned by 328.Dq root 329and unwritable by anyone (mode 555). 330The program 331.Xr ls 1 332must be present to support the list command. 333This program should be mode 111. 334.It Pa ~ftp/etc 335Make this directory owned by 336.Dq root 337and unwritable by anyone (mode 555). 338The files pwd.db (see 339.Xr passwd 5 ) 340and 341.Xr group 5 342must be present for the 343.Xr ls 344command to be able to produce owner names rather than numbers. 345The password field in 346.Xr passwd 347is not used, and should not contain real passwords. 348The file 349.Pa ftpmotd , 350if present, will be printed after a successful login. 351These files should be mode 444. 352.It Pa ~ftp/pub 353Make this directory mode 777 and owned by 354.Dq ftp . 355Guests 356can then place files which are to be accessible via the anonymous 357account in this directory. 358.El 359.Pp 360If the system has multiple IP addresses, 361.Nm ftpd 362supports the idea of virtual hosts, which provides the ability to 363define multiple anonymous ftp areas, each one allocated to a different 364internet address. 365The file 366.Pa /etc/ftphosts 367contains information pertaining to each of the virtual hosts. 368Each host is defined on its own line which contains a number of 369fields separated by whitespace: 370.Bl -tag -offset indent -width hostname 371.It hostname 372Contains the hostname or IP address of the virtual host. 373.It user 374Contains a user record in the system password file. 375As with normal anonymous ftp, this user's access uid, gid and group 376memberships determine file access to the anonymous ftp area. 377The anonymous ftp area (to which any user is chrooted on login) 378is determined by the home directory defined for the account. 379User id and group for any ftp account may be the same as for the 380standard ftp user. 381.It statfile 382File to which all file transfers are logged, which 383defaults to 384.Pa /var/log/ftpd . 385.It welcome 386This file is the welcome message displayed before the server ready 387prompt. 388It defaults to 389.Pa /etc/ftpwelcome . 390.It motd 391This file is displayed after the user logs in. 392It defaults to 393.Pa /etc/ftpmotd . 394.El 395.Pp 396Defining a virtual host for the primary IP address or hostname 397changes the default for ftp logins to that address. 398The 'user', 'statfile', 'welcome' and 'motd' fields may be left 399blank, or a single hypen '-' used to indicate that the default 400value is to be used. 401.Pp 402As with any anonymous login configuration, due care must be given 403to setup and maintenance to guard against security related problems. 404.Pp 405If compiled with the 406.Em INTERNAL_LS 407option, 408.Nm ftpd 409will have internal support for handling remote requests to list 410files, and will not execute 411.Pa /bin/ls 412in either a chrooted or non-chrooted environment. 413In this case, the 414.Pa ~/bin/ls 415executable need not be placed into the chrooted tree, nor need the 416.Pa ~/bin 417directory exist. 418This support may be added by making ftpd with the 419.Em FTP_INTERNAL_LS 420variable set either in 421.Pa /etc/make.conf 422or in the shell's environment. 423.Sh FILES 424.Bl -tag -width /etc/ftpwelcome -compact 425.It Pa /etc/ftpusers 426List of unwelcome/restricted users. 427.It Pa /etc/ftpchroot 428List of normal users who should be chroot'd. 429.It Pa /etc/ftpwelcome 430Welcome notice. 431.It Pa /etc/ftpmotd 432Welcome notice after login. 433.It Pa /etc/nologin 434Displayed and access refused. 435.It Pa /var/log/ftpd 436Log file for anonymous transfers. 437.El 438.Sh SEE ALSO 439.Xr ftp 1 , 440.Xr key 1 , 441.Xr getusershell 3 , 442.Xr login.conf 5 , 443.Xr inetd 8 , 444.Xr syslogd 8 445.Sh BUGS 446The server must run as the super-user 447to create sockets with privileged port numbers. It maintains 448an effective user id of the logged in user, reverting to 449the super-user only when binding addresses to sockets. The 450possible security holes have been extensively 451scrutinized, but are possibly incomplete. 452.Sh HISTORY 453The 454.Nm 455command appeared in 456.Bx 4.2 . 457