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