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