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