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