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