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