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