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