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. 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, 249.Pa /etc/pwd.db , 250and not have a null password. 251In this case a password must be provided by the client before any 252file operations may be performed. 253If the user has an S/Key key, the response from a successful USER 254command will include an S/Key challenge. The client may choose to respond 255with a PASS command giving either a standard password or an S/Key 256one-time password. The server will automatically determine which type of 257password it has been given and attempt to authenticate accordingly. See 258.Xr key 1 259for more information on S/Key authentication. S/Key is a Trademark of 260Bellcore. 261.It 262The login name must not appear in the file 263.Pa /etc/ftpusers . 264.It 265The user must have a standard shell returned by 266.Xr getusershell 3 . 267.It 268If the user name appears in the file 269.Pa /etc/ftpchroot 270the session's root will be changed to the user's login directory by 271.Xr chroot 2 272as for an 273.Dq anonymous 274or 275.Dq ftp 276account (see next item). However, the user must still supply a password. 277This feature is intended as a compromise between a fully anonymous account 278and a fully privileged account. The account should also be set up as for an 279anonymous account. 280.It 281If the user name is 282.Dq anonymous 283or 284.Dq ftp , 285an 286anonymous ftp account must be present in the password 287file (user 288.Dq ftp ) . 289In this case the user is allowed 290to log in by specifying any password (by convention an email address for 291the user should be used as the password). 292When the 293.Fl S 294option is set, all transfers are logged as well. 295.El 296.Pp 297In the last case, 298.Nm ftpd 299takes special measures to restrict the client's access privileges. 300The server performs a 301.Xr chroot 2 302to the home directory of the 303.Dq ftp 304user. 305In order that system security is not breached, it is recommended 306that the 307.Dq ftp 308subtree be constructed with care, following these rules: 309.Bl -tag -width "~ftp/pub" -offset indent 310.It Pa ~ftp 311Make the home directory owned by 312.Dq root 313and unwritable by anyone. 314.It Pa ~ftp/bin 315Make this directory owned by 316.Dq root 317and unwritable by anyone (mode 555). 318The program 319.Xr ls 1 320must be present to support the list command. 321This program should be mode 111. 322.It Pa ~ftp/etc 323Make this directory owned by 324.Dq root 325and unwritable by anyone (mode 555). 326The files pwd.db (see 327.Xr passwd 5 ) 328and 329.Xr group 5 330must be present for the 331.Xr ls 332command to be able to produce owner names rather than numbers. 333The password field in 334.Xr passwd 335is not used, and should not contain real passwords. 336The file 337.Pa ftpmotd , 338if present, will be printed after a successful login. 339These files should be mode 444. 340.It Pa ~ftp/pub 341Make this directory mode 777 and owned by 342.Dq ftp . 343Guests 344can then place files which are to be accessible via the anonymous 345account in this directory. 346.El 347.Sh FILES 348.Bl -tag -width /etc/ftpwelcome -compact 349.It Pa /etc/ftpusers 350List of unwelcome/restricted users. 351.It Pa /etc/ftpchroot 352List of normal users who should be chroot'd. 353.It Pa /etc/ftpwelcome 354Welcome notice. 355.It Pa /etc/ftpmotd 356Welcome notice after login. 357.It Pa /etc/nologin 358Displayed and access refused. 359.It Pa /var/log/ftpd 360Log file for anonymous transfers. 361.El 362.Sh SEE ALSO 363.Xr ftp 1 , 364.Xr key 1 , 365.Xr getusershell 3 , 366.Xr inetd 8 , 367.Xr syslogd 8 368.Sh BUGS 369The server must run as the super-user 370to create sockets with privileged port numbers. It maintains 371an effective user id of the logged in user, reverting to 372the super-user only when binding addresses to sockets. The 373possible security holes have been extensively 374scrutinized, but are possibly incomplete. 375.Sh HISTORY 376The 377.Nm 378command appeared in 379.Bx 4.2 . 380