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