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