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