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