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