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