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