1.\" $NetBSD: ftpd.8,v 1.7 1995/04/11 02:44:53 cgd Exp $ 2.\" 3.\" Copyright (c) 1985, 1988, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94 35.\" 36.Dd July 19, 2003 37.Dt FTPD 8 38.Os BSD 4.2 39.Sh NAME 40.Nm ftpd 41.Nd Internet File Transfer Protocol server 42.Sh SYNOPSIS 43.Nm 44.Op Fl a Ar authmode 45.Op Fl dilvU 46.Op Fl g Ar umask 47.Op Fl p Ar port 48.Op Fl T Ar maxtimeout 49.Op Fl t Ar timeout 50.Op Fl -gss-bindings 51.Op Fl u Ar default umask 52.Op Fl B | Fl -builtin-ls 53.Op Fl -good-chars= Ns Ar string 54.Sh DESCRIPTION 55.Nm Ftpd 56is the 57Internet File Transfer Protocol 58server process. The server uses the 59.Tn TCP 60protocol 61and listens at the port specified in the 62.Dq ftp 63service specification; see 64.Xr services 5 . 65.Pp 66Available options: 67.Bl -tag -width Ds 68.It Fl a 69Select the level of authentication required. Kerberised login can not 70be turned off. The default is to only allow kerberised login. Other 71possibilities can be turned on by giving a string of comma separated 72flags as argument to 73.Fl a . 74Recognised flags are: 75.Bl -tag -width plain 76.It Ar plain 77Allow logging in with plaintext password. The password can be a(n) OTP 78or an ordinary password. 79.It Ar otp 80Same as 81.Ar plain , 82but only OTP is allowed. 83.It Ar ftp 84Allow anonymous login. 85.El 86.Pp 87The following combination modes exists for backwards compatibility: 88.Bl -tag -width plain 89.It Ar none 90Same as 91.Ar plain,ftp . 92.It Ar safe 93Same as 94.Ar ftp . 95.It Ar user 96Ignored. 97.El 98.It Fl d 99Debugging information is written to the syslog using LOG_FTP. 100.It Fl g 101Anonymous users will get a umask of 102.Ar umask . 103.It Fl -gss-bindings 104require the peer to use GSS-API bindings (ie make sure IP addresses match). 105.It Fl i 106Open a socket and wait for a connection. This is mainly used for 107debugging when ftpd isn't started by inetd. 108.It Fl l 109Each successful and failed 110.Xr ftp 1 111session is logged using syslog with a facility of LOG_FTP. 112If this option is specified twice, the retrieve (get), store (put), append, 113delete, make directory, remove directory and rename operations and 114their filename arguments are also logged. 115.It Fl p 116Use 117.Ar port 118(a service name or number) instead of the default 119.Ar ftp/tcp . 120.It Fl T 121A client may also request a different timeout period; 122the maximum period allowed may be set to 123.Ar timeout 124seconds with the 125.Fl T 126option. 127The default limit is 2 hours. 128.It Fl t 129The inactivity timeout period is set to 130.Ar timeout 131seconds (the default is 15 minutes). 132.It Fl u 133Set the initial umask to something else than the default 027. 134.It Fl U 135In previous versions of 136.Nm ftpd , 137when a passive mode client requested a data connection to the server, the 138server would use data ports in the range 1024..4999. Now, by default, 139if the system supports the IP_PORTRANGE socket option, the server will 140use data ports in the range 49152..65535. Specifying this option will 141revert to the old behavior. 142.It Fl v 143Verbose mode. 144.It Xo 145.Fl B , 146.Fl -builtin-ls 147.Xc 148use built-in ls to list files 149.It Xo 150.Fl -good-chars= Ns Ar string 151.Xc 152allowed anonymous upload filename chars 153.El 154.Pp 155The file 156.Pa /etc/nologin 157can be used to disable ftp access. 158If the file exists, 159.Nm 160displays it and exits. 161If the file 162.Pa /etc/ftpwelcome 163exists, 164.Nm 165prints it before issuing the 166.Dq ready 167message. 168If the file 169.Pa /etc/motd 170exists, 171.Nm 172prints it after a successful login. 173.Pp 174The ftp server currently supports the following ftp requests. 175The case of the requests is ignored. 176.Bl -column "Request" -offset indent 177.It Request Ta "Description" 178.It ABOR Ta "abort previous command" 179.It ACCT Ta "specify account (ignored)" 180.It ALLO Ta "allocate storage (vacuously)" 181.It APPE Ta "append to a file" 182.It CDUP Ta "change to parent of current working directory" 183.It CWD Ta "change working directory" 184.It DELE Ta "delete a file" 185.It HELP Ta "give help information" 186.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA" 187.It MKD Ta "make a directory" 188.It MDTM Ta "show last modification time of file" 189.It MODE Ta "specify data transfer" Em mode 190.It NLST Ta "give name list of files in directory" 191.It NOOP Ta "do nothing" 192.It PASS Ta "specify password" 193.It PASV Ta "prepare for server-to-server transfer" 194.It PORT Ta "specify data connection port" 195.It PWD Ta "print the current working directory" 196.It QUIT Ta "terminate session" 197.It REST Ta "restart incomplete transfer" 198.It RETR Ta "retrieve a file" 199.It RMD Ta "remove a directory" 200.It RNFR Ta "specify rename-from file name" 201.It RNTO Ta "specify rename-to file name" 202.It SITE Ta "non-standard commands (see next section)" 203.It SIZE Ta "return size of file" 204.It STAT Ta "return status of server" 205.It STOR Ta "store a file" 206.It STOU Ta "store a file with a unique name" 207.It STRU Ta "specify data transfer" Em structure 208.It SYST Ta "show operating system type of server system" 209.It TYPE Ta "specify data transfer" Em type 210.It USER Ta "specify user name" 211.It XCUP Ta "change to parent of current working directory (deprecated)" 212.It XCWD Ta "change working directory (deprecated)" 213.It XMKD Ta "make a directory (deprecated)" 214.It XPWD Ta "print the current working directory (deprecated)" 215.It XRMD Ta "remove a directory (deprecated)" 216.El 217.Pp 218The following commands are specified by RFC2228. 219.Bl -column Request -offset indent 220.It AUTH Ta "authentication/security mechanism" 221.It ADAT Ta "authentication/security data" 222.It PROT Ta "data channel protection level" 223.It PBSZ Ta "protection buffer size" 224.It MIC Ta "integrity protected command" 225.It CONF Ta "confidentiality protected command" 226.It ENC Ta "privacy protected command" 227.It CCC Ta "clear command channel" 228.El 229.Pp 230The following non-standard or 231.Tn UNIX 232specific commands are supported 233by the 234SITE request. 235.Pp 236.Bl -column Request -offset indent 237.It UMASK Ta change umask, (e.g. 238.Ic "SITE UMASK 002" ) 239.It IDLE Ta set idle-timer, (e.g. 240.Ic "SITE IDLE 60" ) 241.It CHMOD Ta change mode of a file (e.g. 242.Ic "SITE CHMOD 755 filename" ) 243.It FIND Ta quickly find a specific file with GNU 244.Xr locate 1 . 245.It HELP Ta give help information. 246.El 247.Pp 248The following Kerberos related site commands are understood. 249.Bl -column Request -offset indent 250.It KAUTH Ta obtain remote tickets. 251.It KLIST Ta show remote tickets 252.El 253.Pp 254The remaining ftp requests specified in Internet RFC 959 255are 256recognized, but not implemented. 257MDTM and SIZE are not specified in RFC 959, but will appear in the 258next updated FTP RFC. 259.Pp 260The ftp server will abort an active file transfer only when the 261ABOR 262command is preceded by a Telnet "Interrupt Process" (IP) 263signal and a Telnet "Synch" signal in the command Telnet stream, 264as described in Internet RFC 959. 265If a 266STAT 267command is received during a data transfer, preceded by a Telnet IP 268and Synch, transfer status will be returned. 269.Pp 270.Nm Ftpd 271interprets file names according to the 272.Dq globbing 273conventions used by 274.Xr csh 1 . 275This allows users to use the metacharacters 276.Dq Li \&*?[]{}~ . 277.Pp 278.Nm Ftpd 279authenticates users according to these rules. 280.Pp 281.Bl -enum -offset indent 282.It 283If Kerberos authentication is used, the user must pass valid tickets 284and the principal must be allowed to login as the remote user. 285.It 286The login name must be in the password data base, and not have a null 287password (if Kerberos is used the password field is not checked). In 288this case a password must be provided by the client before any file 289operations may be performed. If the user has an OTP key, the response 290from a successful USER command will include an OTP challenge. The 291client may choose to respond with a PASS command giving either a 292standard password or an OTP one-time password. The server will 293automatically determine which type of password it has been given and 294attempt to authenticate accordingly. See 295.Xr otp 1 296for more information on OTP authentication. 297.It 298The login name must not appear in the file 299.Pa /etc/ftpusers . 300.It 301The user must have a standard shell returned by 302.Xr getusershell 3 . 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). However, the user must still supply a password. 313This feature is intended as a compromise between a fully anonymous account 314and a fully privileged account. The account should also be set up as for an 315anonymous account. 316.It 317If the user name is 318.Dq anonymous 319or 320.Dq ftp , 321an 322anonymous ftp account must be present in the password 323file (user 324.Dq ftp ) . 325In this case the user is allowed 326to log in by specifying any password (by convention an email address for 327the user should be used as the password). 328.El 329.Pp 330In the last case, 331.Nm ftpd 332takes special measures to restrict the client's access privileges. 333The server performs a 334.Xr chroot 2 335to the home directory of the 336.Dq ftp 337user. 338In order that system security is not breached, it is recommended 339that the 340.Dq ftp 341subtree be constructed with care, consider following these guidelines 342for anonymous ftp. 343.Pp 344In general all files should be owned by 345.Dq root , 346and have non-write permissions (644 or 755 depending on the kind of 347file). No files should be owned or writable by 348.Dq ftp 349(possibly with exception for the 350.Pa ~ftp/incoming , 351as specified below). 352.Bl -tag -width "~ftp/pub" -offset indent 353.It Pa ~ftp 354The 355.Dq ftp 356homedirectory should be owned by root. 357.It Pa ~ftp/bin 358The directory for external programs (such as 359.Xr ls 1 ) . 360These programs must either be statically linked, or you must setup an 361environment for dynamic linking when running chrooted. 362These programs will be used if present: 363.Bl -tag -width "locate" -offset indent 364.It ls 365Used when listing files. 366.It compress 367When retrieving a filename that ends in 368.Pa .Z , 369and that file isn't present, 370.Nm 371will try to find the filename without 372.Pa .Z 373and compress it on the fly. 374.It gzip 375Same as compress, just with files ending in 376.Pa .gz . 377.It gtar 378Enables retrieval of whole directories as files ending in 379.Pa .tar . 380Can also be combined with compression. You must use GNU Tar (or some 381other that supports the 382.Fl z 383and 384.Fl Z 385flags). 386.It locate 387Will enable ``fast find'' with the 388.Ic SITE FIND 389command. You must also create a 390.Pa locatedb 391file in 392.Pa ~ftp/etc . 393.El 394.It Pa ~ftp/etc 395If you put copies of the 396.Xr passwd 5 397and 398.Xr group 5 399files here, ls will be able to produce owner names rather than 400numbers. Remember to remove any passwords from these files. 401.Pp 402The file 403.Pa motd , 404if present, will be printed after a successful login. 405.It Pa ~ftp/dev 406Put a copy of 407.Xr /dev/null 7 408here. 409.It Pa ~ftp/pub 410Traditional place to put whatever you want to make public. 411.El 412.Pp 413If you want guests to be able to upload files, create a 414.Pa ~ftp/incoming 415directory owned by 416.Dq root , 417and group 418.Dq ftp 419with mode 730 (make sure 420.Dq ftp 421is member of group 422.Dq ftp ) . 423The following restrictions apply to anonymous users: 424.Bl -bullet 425.It 426Directories created will have mode 700. 427.It 428Uploaded files will be created with an umask of 777, if not changed 429with the 430.Fl g 431option. 432.It 433These command are not accessible: 434.Ic DELE , RMD , RNTO , RNFR , 435.Ic SITE UMASK , 436and 437.Ic SITE CHMOD . 438.It 439Filenames must start with an alpha-numeric character, and consist of 440alpha-numeric characters or any of the following: 441.Li \&+ 442(plus), 443.Li \&- 444(minus), 445.Li \&= 446(equal), 447.Li \&_ 448(underscore), 449.Li \&. 450(period), and 451.Li \&, 452(comma). 453.El 454.Sh FILES 455.Bl -tag -width /etc/ftpwelcome -compact 456.It Pa /etc/ftpusers 457Access list for users. 458.It Pa /etc/ftpchroot 459List of normal users who should be chroot'd. 460.It Pa /etc/ftpwelcome 461Welcome notice. 462.It Pa /etc/motd 463Welcome notice after login. 464.It Pa /etc/nologin 465Displayed and access refused. 466.It Pa ~/.klogin 467Login access for Kerberos. 468.El 469.Sh SEE ALSO 470.Xr ftp 1 , 471.Xr otp 1 , 472.Xr getusershell 3 , 473.Xr ftpusers 5 , 474.Xr syslogd 8 475.Sh STANDARDS 476.Bl -tag -compact -width "RFC 1938" 477.It Cm RFC 959 478FTP PROTOCOL SPECIFICATION 479.It Cm RFC 1938 480OTP Specification 481.It Cm RFC 2228 482FTP Security Extensions. 483.El 484.Sh BUGS 485The server must run as the super-user 486to create sockets with privileged port numbers. It maintains 487an effective user id of the logged in user, reverting to 488the super-user only when binding addresses to sockets. The 489possible security holes have been extensively 490scrutinized, but are possibly incomplete. 491.Sh HISTORY 492The 493.Nm 494command appeared in 495.Bx 4.2 . 496