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