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