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