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.\" 34.Dd April 19, 1994 35.Dt FTPD 8 36.Os BSD 4.2 37.Sh NAME 38.Nm ftpd 39.Nd 40Internet File Transfer Protocol server 41.Sh SYNOPSIS 42.Nm ftpd 43.Op Fl dl 44.Op Fl T Ar maxtimeout 45.Op Fl t Ar timeout 46.Sh DESCRIPTION 47.Nm Ftpd 48is the 49Internet File Transfer Protocol 50server process. The server uses the 51.Tn TCP 52protocol 53and listens at the port specified in the 54.Dq ftp 55service specification; see 56.Xr services 5 . 57.Pp 58Available options: 59.Bl -tag -width Ds 60.It Fl d 61Debugging information is written to the syslog using LOG_FTP. 62.It Fl l 63Each successful and failed 64.Xr ftp 1 65session is logged using syslog with a facility of LOG_FTP. 66If this option is specified twice, the retrieve (get), store (put), append, 67delete, make directory, remove directory and rename operations and 68their filename arguments are also logged. 69.It Fl T 70A client may also request a different timeout period; 71the maximum period allowed may be set to 72.Ar timeout 73seconds with the 74.Fl T 75option. 76The default limit is 2 hours. 77.It Fl t 78The inactivity timeout period is set to 79.Ar timeout 80seconds (the default is 15 minutes). 81.El 82.Pp 83The file 84.Pa /etc/nologin 85can be used to disable ftp access. 86If the file exists, 87.Nm 88displays it and exits. 89If the file 90.Pa /etc/ftpwelcome 91exists, 92.Nm 93prints it before issuing the 94.Dq ready 95message. 96If the file 97.Pa /etc/motd 98exists, 99.Nm 100prints it after a successful login. 101.Pp 102The ftp server currently supports the following ftp requests. 103The case of the requests is ignored. 104.Bl -column "Request" -offset indent 105.It Request Ta "Description" 106.It ABOR Ta "abort previous command" 107.It ACCT Ta "specify account (ignored)" 108.It ALLO Ta "allocate storage (vacuously)" 109.It APPE Ta "append to a file" 110.It CDUP Ta "change to parent of current working directory" 111.It CWD Ta "change working directory" 112.It DELE Ta "delete a file" 113.It HELP Ta "give help information" 114.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" 115.It MKD Ta "make a directory" 116.It MDTM Ta "show last modification time of file" 117.It MODE Ta "specify data transfer" Em mode 118.It NLST Ta "give name list of files in directory" 119.It NOOP Ta "do nothing" 120.It PASS Ta "specify password" 121.It PASV Ta "prepare for server-to-server transfer" 122.It PORT Ta "specify data connection port" 123.It PWD Ta "print the current working directory" 124.It QUIT Ta "terminate session" 125.It REST Ta "restart incomplete transfer" 126.It RETR Ta "retrieve a file" 127.It RMD Ta "remove a directory" 128.It RNFR Ta "specify rename-from file name" 129.It RNTO Ta "specify rename-to file name" 130.It SITE Ta "non-standard commands (see next section)" 131.It SIZE Ta "return size of file" 132.It STAT Ta "return status of server" 133.It STOR Ta "store a file" 134.It STOU Ta "store a file with a unique name" 135.It STRU Ta "specify data transfer" Em structure 136.It SYST Ta "show operating system type of server system" 137.It TYPE Ta "specify data transfer" Em type 138.It USER Ta "specify user name" 139.It XCUP Ta "change to parent of current working directory (deprecated)" 140.It XCWD Ta "change working directory (deprecated)" 141.It XMKD Ta "make a directory (deprecated)" 142.It XPWD Ta "print the current working directory (deprecated)" 143.It XRMD Ta "remove a directory (deprecated)" 144.El 145.Pp 146The following non-standard or 147.Tn UNIX 148specific commands are supported 149by the 150SITE request. 151.Pp 152.Bl -column Request -offset indent 153.It Sy Request Ta Sy Description 154.It UMASK Ta change umask, e.g. ``SITE UMASK 002'' 155.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60'' 156.It CHMOD Ta change mode of a file, e.g. ``SITE CHMOD 755 filename'' 157.It HELP Ta give help information. 158.El 159.Pp 160The remaining ftp requests specified in Internet RFC 959 161are 162recognized, but not implemented. 163MDTM and SIZE are not specified in RFC 959, but will appear in the 164next updated FTP RFC. 165.Pp 166The ftp server will abort an active file transfer only when the 167ABOR 168command is preceded by a Telnet "Interrupt Process" (IP) 169signal and a Telnet "Synch" signal in the command Telnet stream, 170as described in Internet RFC 959. 171If a 172STAT 173command is received during a data transfer, preceded by a Telnet IP 174and Synch, transfer status will be returned. 175.Pp 176.Nm Ftpd 177interprets file names according to the 178.Dq globbing 179conventions used by 180.Xr csh 1 . 181This allows users to utilize the metacharacters 182.Dq Li \&*?[]{}~ . 183.Pp 184.Nm Ftpd 185authenticates users according to three rules. 186.Pp 187.Bl -enum -offset indent 188.It 189The login name must be in the password data base, 190.Pa /etc/passwd , 191and not have a null password. 192In this case a password must be provided by the client before any 193file operations may be performed. 194.It 195The login name must not appear in the file 196.Pa /etc/ftpusers . 197.It 198The user must have a standard shell returned by 199.Xr getusershell 3 . 200.It 201If the user name is 202.Dq anonymous 203or 204.Dq ftp , 205an 206anonymous ftp account must be present in the password 207file (user 208.Dq ftp ) . 209In this case the user is allowed 210to log in by specifying any password (by convention an email address for 211the user should be used as the password). 212.El 213.Pp 214In the last case, 215.Nm ftpd 216takes special measures to restrict the client's access privileges. 217The server performs a 218.Xr chroot 2 219to the home directory of the 220.Dq ftp 221user. 222In order that system security is not breached, it is recommended 223that the 224.Dq ftp 225subtree be constructed with care, following these rules: 226.Bl -tag -width "~ftp/pub" -offset indent 227.It Pa ~ftp 228Make the home directory owned by 229.Dq root 230and unwritable by anyone. 231.It Pa ~ftp/bin 232Make this directory owned by 233.Dq root 234and unwritable by anyone (mode 555). 235The program 236.Xr ls 1 237must be present to support the list command. 238This program should be mode 111. 239.It Pa ~ftp/etc 240Make this directory owned by 241.Dq root 242and unwritable by anyone (mode 555). 243The files 244.Xr passwd 5 245and 246.Xr group 5 247must be present for the 248.Xr ls 249command to be able to produce owner names rather than numbers. 250The password field in 251.Xr passwd 252is not used, and should not contain real passwords. 253The file 254.Pa motd , 255if present, will be printed after a successful login. 256These files should be mode 444. 257.It Pa ~ftp/pub 258Make this directory mode 777 and owned by 259.Dq ftp . 260Guests 261can then place files which are to be accessible via the anonymous 262account in this directory. 263.El 264.Sh FILES 265.Bl -tag -width /etc/ftpwelcome -compact 266.It Pa /etc/ftpusers 267List of unwelcome/restricted users. 268.It Pa /etc/ftpwelcome 269Welcome notice. 270.It Pa /etc/motd 271Welcome notice after login. 272.It Pa /etc/nologin 273Displayed and access refused. 274.El 275.Sh SEE ALSO 276.Xr ftp 1 , 277.Xr getusershell 3 , 278.Xr syslogd 8 279.Sh BUGS 280The server must run as the super-user 281to create sockets with privileged port numbers. It maintains 282an effective user id of the logged in user, reverting to 283the super-user only when binding addresses to sockets. The 284possible security holes have been extensively 285scrutinized, but are possibly incomplete. 286.Sh HISTORY 287The 288.Nm 289command appeared in 290.Bx 4.2 . 291