1.\" $MirOS: src/libexec/ftpd/ftpd.8,v 1.4 2005/11/23 16:03:57 tg Exp $ 2.\" $OpenBSD: ftpd.8,v 1.64 2005/09/09 23:12:37 jmc Exp $ 3.\" $NetBSD: ftpd.8,v 1.8 1996/01/14 20:55:23 thorpej Exp $ 4.\" 5.\" Copyright (c) 1985, 1988, 1991, 1993 6.\" The Regents of the University of California. All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. 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.\" 34.Dd June 18, 1996 35.Dt FTPD 8 36.Os 37.Sh NAME 38.Nm ftpd 39.Nd Internet File Transfer Protocol server 40.Sh SYNOPSIS 41.Nm ftpd 42.Op Fl 46ADdflMnPSU 43.Op Fl T Ar maxtimeout 44.Op Fl t Ar timeout 45.Op Fl u Ar mask 46.Sh DESCRIPTION 47.Nm 48is the Internet File Transfer Protocol server process. 49The server uses the 50.Tn TCP 51protocol 52and listens at the port specified in the 53.Dq ftp 54service specification; see 55.Xr services 5 . 56.Pp 57The options are as follows: 58.Bl -tag -width Ds 59.It Fl 4 60When 61.Fl D 62is specified, forces 63.Nm 64to use IPv4 addresses only. 65.It Fl 6 66When 67.Fl D 68is specified, forces 69.Nm 70to use IPv6 addresses only. 71.It Fl A 72Permit only anonymous FTP connections 73(unless the 74.Fl n 75option is specified), 76accounts listed in 77.Pa /etc/ftpchroot 78or users in a login class with the 79.Dq ftp-chroot 80variable set (see below). 81Other connection attempts are refused. 82.It Fl D 83With this option set, 84.Nm 85will detach and become a daemon, accepting connections on the FTP port and 86forking child processes to handle them. 87This has lower overhead than starting 88.Nm 89from 90.Xr inetd 8 91and is thus useful on busy servers to reduce load. 92.It Fl d 93Debugging information is written to the syslog using 94.Dv LOG_FTP . 95.It Fl f 96Disables the DELE and RMD commands for anonymous users. 97.It Fl l 98Each successful and failed 99FTP session is logged using syslog with a facility of 100.Dv LOG_FTP . 101If this option is specified twice, the retrieve (get), store (put), append, 102delete, make directory, remove directory and rename operations and 103their filename arguments are also logged. 104.It Fl M 105Enables multihomed mode. 106Instead of simply using 107.Pa ~ftp 108for anonymous transfers, a directory matching the fully qualified name of 109the IP number the client connected to, and located inside 110.Pa ~ftp , 111is used instead. 112.It Fl n 113Do not permit anonymous FTP logins. 114Normally they are permitted. 115.It Fl P 116Permit illegal port numbers or addresses for PORT command initiated connects. 117By default 118.Nm 119violates the RFC and thus constrains the PORT command to non-reserved ports 120and requires it use the same source address as the connection came from. 121This prevents the "FTP bounce attack" against services on both the local 122machine and other local machines. 123.It Fl S 124With this option set, 125.Nm 126logs all anonymous downloads to the file 127.Pa /var/log/ftpd 128when this file exists. 129.It Fl T Ar maxtimeout 130A client may also request a different timeout period; 131the maximum period allowed may be set to 132.Ar maxtimeout 133seconds with the 134.Fl T 135option. 136The default limit is 2 hours. 137.It Fl t Ar timeout 138The inactivity timeout period is set to 139.Ar timeout 140seconds (the default is 15 minutes). 141.It Fl U 142Each concurrent 143FTP session is logged to the file 144.Pa /var/run/utmp , 145making them visible to commands such as 146.Xr who 1 . 147.It Fl u Ar mask 148Force the umask to 149.Ar mask , 150instead of the default specified in 151.Pa /etc/login.conf 152(usually 022). 153Also disallows chmod. 154.El 155.Pp 156The file 157.Pa /etc/nologin 158can be used to disable FTP access. 159If the file exists, 160.Nm 161displays it and exits. 162Note: this method will disable 163.Em all 164non-root logins; see 165.Xr login 1 166for further details. 167If the file 168.Pa /etc/ftpwelcome 169exists, 170.Nm 171prints it before issuing the 172.Dq ready 173message. 174If the welcome file exists 175.Pa ( /etc/motd 176by default), 177.Nm 178prints it after a successful login. 179If the file 180.Pa .message 181exists in a directory, 182.Nm 183prints it when that directory is entered. 184.Pp 185The FTP server currently supports the following FTP requests. 186The case of the requests is ignored. 187.Bl -column "Request" -offset indent 188.It Sy Request Ta Sy Description 189.It ABOR Ta "abort previous command" 190.It ACCT Ta "specify account (not implemented)" 191.It ALLO Ta "allocate storage (vacuously)" 192.It APPE Ta "append to a file" 193.It CDUP Ta "change to parent of current working directory" 194.It CWD Ta "change working directory" 195.It DELE Ta "delete a file" 196.It EPRT Ta "specify data connection port" 197.It EPSV Ta "prepare for server-to-server transfer" 198.It HELP Ta "give help information" 199.It LIST Ta "give list of files in a directory" Pq Li "ls -lgA" 200.It LPRT Ta "specify data connection port" 201.It LPSV Ta "prepare for server-to-server transfer" 202.It MDTM Ta "show last modification time of file" 203.It MKD Ta "make a directory" 204.It MODE Ta "specify data transfer" Em mode 205.It NLST Ta "give name list of files in directory" 206.It NOOP Ta "do nothing" 207.It PASS Ta "specify password" 208.It PASV Ta "prepare for server-to-server transfer" 209.It PORT Ta "specify data connection port" 210.It PWD Ta "print the current working directory" 211.It QUIT Ta "terminate session" 212.It REIN Ta "reinitialize (not implemented)" 213.It REST Ta "restart incomplete transfer" 214.It RETR Ta "retrieve a file" 215.It RMD Ta "remove a directory" 216.It RNFR Ta "specify rename-from file name" 217.It RNTO Ta "specify rename-to file name" 218.It SITE Ta "non-standard commands (see next section)" 219.It SIZE Ta "return size of file" 220.It SMNT Ta "structure mount (not implemented)" 221.It STAT Ta "return status of server" 222.It STOR Ta "store a file" 223.It STOU Ta "store a file with a unique name" 224.It STRU Ta "specify data transfer" Em structure 225.It SYST Ta "show operating system type of server system" 226.It TYPE Ta "specify data transfer" Em type 227.It USER Ta "specify user name; not valid after login" 228.It XCUP Ta "change to parent of current working directory (deprec.)" 229.It XCWD Ta "change working directory (deprecated)" 230.It XMKD Ta "make a directory (deprecated)" 231.It XPWD Ta "print the current working directory (deprecated)" 232.It XRMD Ta "remove a directory (deprecated)" 233.El 234.Pp 235The following non-standard or 236.Tn UNIX 237specific commands are supported 238by the 239SITE request: 240.Bl -column Request -offset indent 241.It Sy Request Ta Sy Description 242.It CHMOD Ta "change mode of a file, e.g., SITE CHMOD 755 filename" 243.It HELP Ta "give help information" 244.It IDLE Ta "set idle-timer, e.g., SITE IDLE 60" 245.It UMASK Ta "change umask, e.g., SITE UMASK 002" 246.El 247.Pp 248The remaining FTP requests specified in Internet RFC 959 are recognized, 249but not implemented. 250MDTM and SIZE are not specified in RFC 959, 251but will appear in the next updated FTP RFC. 252.Pp 253The FTP server will abort an active file transfer only when the 254ABOR 255command is preceded by a Telnet "Interrupt Process" (IP) 256signal and a Telnet "Synch" signal in the command Telnet stream, 257as described in Internet RFC 959. 258If a 259STAT 260command is received during a data transfer, preceded by a Telnet IP 261and Synch, transfer status will be returned. 262.Pp 263.Nm 264interprets file names according to the 265.Dq globbing 266conventions used by 267.Xr csh 1 . 268This allows users to utilize the metacharacters 269.Dq Li \&*?[]{}~ . 270.Pp 271.Nm 272authenticates users by using the service and type of 273.Ar ftp , 274as defined in the 275.Pa /etc/login.conf 276file (see 277.Xr login.conf 5 ) . 278An authentication style 279may be specified by appending with a colon 280.Pq Sq \&: 281following the authentication style, i.e.\& 282.Dq joe:skey . 283The allowed authentication styles for 284.Nm 285may be explicitly specified by the 286.Dq auth-ftp 287entry in 288.Pa /etc/login.conf . 289.Pp 290.Nm 291authenticates users according to five rules. 292.Bl -enum -offset indent 293.It 294The login name must be in the password database and not have a null password. 295In this case a password must be provided by the client before any 296file operations may be performed. 297.It 298The login name must not appear in the file 299.Pa /etc/ftpusers . 300.It 301The user must have a standard shell as described by 302.Xr shells 5 . 303.It 304If the user name appears in the file 305.Pa /etc/ftpchroot , 306the session's root will be changed to the user's login directory by 307.Xr chroot 2 308as for an 309.Dq anonymous 310or 311.Dq ftp 312account (see next item). 313However, the user must still supply a password. 314This feature is intended as a compromise between a fully anonymous account 315and a fully privileged account. 316The account should also be set up as for an anonymous account. 317.It 318If the user name is 319.Dq anonymous 320or 321.Dq ftp , 322an 323anonymous FTP account must be present in the password 324file (user 325.Dq ftp ) . 326In this case the user is allowed 327to log in by specifying any password (by convention an email address for 328the user should be used as the password). 329.El 330.Pp 331Once a user is authenticated the user must be approved by any approval 332script defined (see 333.Xr login.conf 5 ) . 334If a valid approval script (by either :approve=...: or :approve-ftp=...: 335for the user's class) is defined then it is run and must exit with a 0 336(success) status. 337When 338.Nm 339is running under the 340.Fl D 341flag (and debugging is not turned on) then the approval script will be 342called with at least the following variables specified via the 343.Fl v 344option (see 345.Xr login.conf 5 ) 346to the approve script: 347.Bl -column "Variable" -offset indent 348.It Sy Variable Ta Sy Description 349.It FTPD_HOST Ta "The server's (virtual) hostname" 350.El 351.Pp 352For example (the line is broken to fit the page): 353.Bd -literal -offset indent 354/usr/libexec/auth/approve_ftpd -v FTPD_HOST=ftp.mycompany.com \e 355 username class service 356.Ed 357.Pp 358When the user logs in to the anonymous FTP account, 359.Nm 360takes special measures to restrict the client's access privileges. 361The server performs a 362.Xr chroot 2 363to the home directory of the 364.Dq ftp 365user. 366In order that system security is not breached, it is recommended 367that the 368.Dq ftp 369subtree be constructed with care, following these rules: 370.Bl -tag -width "~ftp/pub" -offset indent 371.It Pa ~ftp 372Make the home directory owned by 373.Dq root 374and unwritable by anyone (mode 555). 375.It Pa ~ftp/bin 376Make this directory owned by 377.Dq root 378and unwritable by anyone (mode 511). 379This directory is optional unless you have commands you wish 380the anonymous FTP user to be able to run (the 381.Xr ls 1 382command exists as a built-in). 383Any programs in this directory should be mode 111 (executable only). 384.It Pa ~ftp/etc 385Make this directory owned by 386.Dq root 387and unwritable by anyone (mode 511). 388The files pwd.db (see 389.Xr pwd_mkdb 8 ) 390and 391.Xr group 5 392must be present for the 393.Xr ls 1 394command to be able to produce owner names rather than numbers. 395The password field in 396.Pa pwd.db 397is not used, and should not contain real passwords. 398The file 399.Pa motd , 400if present, will be printed after a successful login. 401These files should be mode 444. 402.It Pa ~ftp/pub 403Make this directory mode 555 and owned by 404.Dq root . 405This is traditionally where publicly accessible files are 406stored for download. 407.El 408.Pp 409If logging to the 410.Pa /var/log/ftpd 411file is enabled, information will be written in the following format: 412.Pp 413.Bl -tag -width XXXXXXXXXXXXXX -offset indent -compact 414.It time 415The time and date of the download, in 416.Xr ctime 3 417format. 418.It elapsed time 419The elapsed time, in seconds. 420.It remote host 421The remote host (or IP number). 422.It bytes 423The number of bytes transferred. 424.It path 425The full path (relative to the FTP chroot space) of the file transferred. 426.It type 427The type of transfer; either 428.Sq a 429for ASCII or 430.Sq b 431for binary. 432.It unused 433Unused field containing a 434.Sq * , 435for compatibility. 436.It unused 437Unused field containing an 438.Sq o , 439for compatibility. 440.It user type 441The type of user; either 442.Sq a 443for anonymous or 444.Sq r 445for a real user (should always be anonymous). 446.It name 447Either a system login name or the value given for 448.Dq email address 449if an anonymous user. 450.It unused 451Unused field containing a 452.Sq 0 , 453for compatibility. 454.It real name 455The system login name if the connection is not anonymous, or a 456.Sq * 457if it is. 458.\" .It virtual host 459.\" The virtual host that the connection was made to. 460.El 461.Pp 462Although fields exist for logging information on real users, this file is 463only used for anonymous downloads. 464Unused fields exist only for compatibility with other 465.Nm 466implementations. 467.Sh LOGIN.CONF VARIABLES 468The 469.Nm 470daemon uses the following FTP-specific parameters: 471.Bl -tag -width ftp-chroot 472.It Pa auth-ftp 473The list of authentication types available to this class. 474See 475.Xr login.conf 5 . 476.It Pa ftp-chroot 477A boolean value. 478If set, users in this class will be automatically chrooted to 479the user's login directory. 480.It Pa ftp-dir 481A path to a directory. 482This value overrides the login directory for users in this class. 483A leading tilde 484.Pq Ql ~ 485in 486.Pa ftp-dir 487will be expanded to the user's home directory based on the 488contents of the password database. 489.It Pa welcome 490The path of the file containing the welcome message. 491If this variable is not set, 492.Pa /etc/motd 493is used. 494.El 495.Sh PORT ALLOCATION 496For passive mode data connections, 497.Nm 498will listen to a random high TCP port. 499The interval of ports used are configurable using 500.Xr sysctl 8 501variables 502.Va net.inet.ip.porthifirst 503and 504.Va net.inet.ip.porthilast . 505.Sh FILES 506.Bl -tag -width /var/run/ftpd.pid -compact 507.It Pa /etc/ftpchroot 508list of normal users who should be chrooted 509.It Pa /etc/ftpusers 510list of unwelcome/restricted users 511.It Pa /etc/ftpwelcome 512welcome notice 513.It Pa /etc/login.conf 514authentication styles 515.It Pa /etc/motd 516printed after a successful login 517.It Pa /etc/nologin 518displayed and access refused 519.It Pa /var/log/ftpd 520log file for anonymous downloads 521.It Pa /var/run/ftpd.pid 522process ID if running in daemon mode 523.It Pa /var/run/utmp 524list of users on the system 525.El 526.Sh SEE ALSO 527.Xr ftp 1 , 528.Xr login 1 , 529.Xr skey 1 , 530.Xr who 1 , 531.Xr chroot 2 , 532.Xr ctime 3 , 533.Xr group 5 , 534.Xr login.conf 5 , 535.Xr motd 5 , 536.Xr services 5 , 537.Xr shells 5 , 538.Xr ftp-proxy 8 , 539.Xr inetd 8 , 540.Xr pwd_mkdb 8 , 541.Xr sysctl 8 , 542.Xr syslogd 8 543.Sh HISTORY 544The 545.Nm 546command appeared in 547.Bx 4.2 . 548As of 549.Mx 8 , 550there is an option to prevent anonymous users from deleting. 551.Sh BUGS 552You ought to not be using the file transfer protocol at all; 553this daemon is only provided for compatibility reasons. 554A suitable alternative is 555.Xr scp 1 , 556as well as 557.Xr sftp 1 ; 558you might use 559.Xr httpd 8 560for simply sharing files, or NFS or CIFS/samba for discs. 561