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