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