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