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