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