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