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