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$ 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. 76.It Fl D 77With this option set, 78.Nm ftpd 79will detach and become a daemon, accepting connections on the FTP port and 80forking children processes to handle them. This is lower overhead than 81starting 82.Nm ftpd 83from 84.Xr inetd 8 85and is thus useful on busy servers to reduce load. 86.It Fl R 87With this option set, 88.Nm ftpd 89will revert to historical behavior with regard to security checks on 90user operations and restrictions on PORT requests. 91Currently, 92.Nm ftpd 93will only honor PORT commands directed to unprivileged ports on the 94remote user's host (which violates the FTP protocol specification but 95closes some security holes). 96. 97.It Fl S 98With this option set, 99.Nm ftpd 100logs all anonymous transfers to the file 101.Pa /var/log/ftpd 102when this file exists. 103. 104.It Fl U 105In previous versions of 106.Nm ftpd , 107when a passive mode client requested a data connection to the server, 108the server would use data ports in the range 1024..4999. Now, by default, 109the server will use data ports in the range 40000..44999. Specifying this 110option will revert to the old behavior. 111.It Fl T 112A client may also request a different timeout period; 113the maximum period allowed may be set to 114.Ar timeout 115seconds with the 116.Fl T 117option. 118The default limit is 2 hours. 119.It Fl t 120The inactivity timeout period is set to 121.Ar timeout 122seconds (the default is 15 minutes). 123.It Fl a 124When 125.Fl D 126is specified, accept connections only on the specified 127.Ar address . 128.It Fl p 129When 130.Fl D 131is specified, write the daemon's process ID to 132.Ar file . 133.El 134.Pp 135The file 136.Pa /etc/nologin 137can be used to disable ftp access. 138If the file exists, 139.Nm 140displays it and exits. 141If the file 142.Pa /etc/ftpwelcome 143exists, 144.Nm 145prints it before issuing the 146.Dq ready 147message. 148If the file 149.Pa /etc/ftpmotd 150exists, 151.Nm 152prints it after a successful login. 153.Pp 154The ftp server currently supports the following ftp requests. 155The case of the requests is ignored. 156.Bl -column "Request" -offset indent 157.It Request Ta "Description" 158.It ABOR Ta "abort previous command" 159.It ACCT Ta "specify account (ignored)" 160.It ALLO Ta "allocate storage (vacuously)" 161.It APPE Ta "append to a file" 162.It CDUP Ta "change to parent of current working directory" 163.It CWD Ta "change working directory" 164.It DELE Ta "delete a file" 165.It HELP Ta "give help information" 166.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" 167.It MKD Ta "make a directory" 168.It MDTM Ta "show last modification time of file" 169.It MODE Ta "specify data transfer" Em mode 170.It NLST Ta "give name list of files in directory" 171.It NOOP Ta "do nothing" 172.It PASS Ta "specify password" 173.It PASV Ta "prepare for server-to-server transfer" 174.It PORT Ta "specify data connection port" 175.It PWD Ta "print the current working directory" 176.It QUIT Ta "terminate session" 177.It REST Ta "restart incomplete transfer" 178.It RETR Ta "retrieve a file" 179.It RMD Ta "remove a directory" 180.It RNFR Ta "specify rename-from file name" 181.It RNTO Ta "specify rename-to file name" 182.It SITE Ta "non-standard commands (see next section)" 183.It SIZE Ta "return size of file" 184.It STAT Ta "return status of server" 185.It STOR Ta "store a file" 186.It STOU Ta "store a file with a unique name" 187.It STRU Ta "specify data transfer" Em structure 188.It SYST Ta "show operating system type of server system" 189.It TYPE Ta "specify data transfer" Em type 190.It USER Ta "specify user name" 191.It XCUP Ta "change to parent of current working directory (deprecated)" 192.It XCWD Ta "change working directory (deprecated)" 193.It XMKD Ta "make a directory (deprecated)" 194.It XPWD Ta "print the current working directory (deprecated)" 195.It XRMD Ta "remove a directory (deprecated)" 196.El 197.Pp 198The following non-standard or 199.Tn UNIX 200specific commands are supported 201by the 202SITE request. 203.Pp 204.Bl -column Request -offset indent 205.It Sy Request Ta Sy Description 206.It UMASK Ta change umask, e.g. ``SITE UMASK 002'' 207.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60'' 208.It CHMOD Ta change mode of a file, e.g. ``SITE CHMOD 755 filename'' 209.It HELP Ta give help information. 210.El 211.Pp 212The remaining ftp requests specified in Internet RFC 959 213are 214recognized, but not implemented. 215MDTM and SIZE are not specified in RFC 959, but will appear in the 216next updated FTP RFC. 217.Pp 218The ftp server will abort an active file transfer only when the 219ABOR 220command is preceded by a Telnet "Interrupt Process" (IP) 221signal and a Telnet "Synch" signal in the command Telnet stream, 222as described in Internet RFC 959. 223If a 224STAT 225command is received during a data transfer, preceded by a Telnet IP 226and Synch, transfer status will be returned. 227.Pp 228.Nm Ftpd 229interprets file names according to the 230.Dq globbing 231conventions used by 232.Xr csh 1 . 233This allows users to utilize the metacharacters 234.Dq Li \&*?[]{}~ . 235.Pp 236.Nm Ftpd 237authenticates users according to five rules. 238.Pp 239.Bl -enum -offset indent 240.It 241The login name must be in the password data base, 242.Pa /etc/pwd.db , 243and not have a null password. 244In this case a password must be provided by the client before any 245file operations may be performed. 246If the user has an S/Key key, the response from a successful USER 247command will include an S/Key challenge. The client may choose to respond 248with a PASS command giving either a standard password or an S/Key 249one-time password. The server will automatically determine which type of 250password it has been given and attempt to authenticate accordingly. See 251.Xr key 1 252for more information on S/Key authentication. S/Key is a Trademark of 253Bellcore. 254.It 255The login name must not appear in the file 256.Pa /etc/ftpusers . 257.It 258The user must have a standard shell returned by 259.Xr getusershell 3 . 260.It 261If the user name appears in the file 262.Pa /etc/ftpchroot 263the session's root will be changed to the user's login directory by 264.Xr chroot 2 265as for an 266.Dq anonymous 267or 268.Dq ftp 269account (see next item). However, the user must still supply a password. 270This feature is intended as a compromise between a fully anonymous account 271and a fully privileged account. The account should also be set up as for an 272anonymous account. 273.It 274If the user name is 275.Dq anonymous 276or 277.Dq ftp , 278an 279anonymous ftp account must be present in the password 280file (user 281.Dq ftp ) . 282In this case the user is allowed 283to log in by specifying any password (by convention an email address for 284the user should be used as the password). 285When the 286.Fl S 287option is set, all transfers are logged as well. 288.El 289.Pp 290In the last case, 291.Nm ftpd 292takes special measures to restrict the client's access privileges. 293The server performs a 294.Xr chroot 2 295to the home directory of the 296.Dq ftp 297user. 298In order that system security is not breached, it is recommended 299that the 300.Dq ftp 301subtree be constructed with care, following these rules: 302.Bl -tag -width "~ftp/pub" -offset indent 303.It Pa ~ftp 304Make the home directory owned by 305.Dq root 306and unwritable by anyone. 307.It Pa ~ftp/bin 308Make this directory owned by 309.Dq root 310and unwritable by anyone (mode 555). 311The program 312.Xr ls 1 313must be present to support the list command. 314This program should be mode 111. 315.It Pa ~ftp/etc 316Make this directory owned by 317.Dq root 318and unwritable by anyone (mode 555). 319The files pwd.db (see 320.Xr passwd 5 ) 321and 322.Xr group 5 323must be present for the 324.Xr ls 325command to be able to produce owner names rather than numbers. 326The password field in 327.Xr passwd 328is not used, and should not contain real passwords. 329The file 330.Pa ftpmotd , 331if present, will be printed after a successful login. 332These files should be mode 444. 333.It Pa ~ftp/pub 334Make this directory mode 777 and owned by 335.Dq ftp . 336Guests 337can then place files which are to be accessible via the anonymous 338account in this directory. 339.El 340.Sh FILES 341.Bl -tag -width /etc/ftpwelcome -compact 342.It Pa /etc/ftpusers 343List of unwelcome/restricted users. 344.It Pa /etc/ftpchroot 345List of normal users who should be chroot'd. 346.It Pa /etc/ftpwelcome 347Welcome notice. 348.It Pa /etc/ftpmotd 349Welcome notice after login. 350.It Pa /etc/nologin 351Displayed and access refused. 352.It Pa /var/log/ftpd 353Log file for anonymous transfers. 354.El 355.Sh SEE ALSO 356.Xr ftp 1 , 357.Xr key 1 , 358.Xr getusershell 3 , 359.Xr inetd 8 , 360.Xr syslogd 8 361.Sh BUGS 362The server must run as the super-user 363to create sockets with privileged port numbers. It maintains 364an effective user id of the logged in user, reverting to 365the super-user only when binding addresses to sockets. The 366possible security holes have been extensively 367scrutinized, but are possibly incomplete. 368.Sh HISTORY 369The 370.Nm 371command appeared in 372.Bx 4.2 . 373