xref: /freebsd/libexec/ftpd/ftpd.8 (revision 952d112864d8008aa87278a30a539d888a8493cd)
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.13 1997/02/22 14:21:27 peter 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 Ds
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 ftpd
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 ftpd
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 ftpd
94will revert to historical behavior with regard to security checks on
95user operations and restrictions on PORT requests.
96Currently,
97.Nm ftpd
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.
102.It Fl S
103With this option set,
104.Nm ftpd
105logs all anonymous transfers to the file
106.Pa /var/log/ftpd
107when this file exists.
108.
109.It Fl U
110In previous versions of
111.Nm ftpd ,
112when a passive mode client requested a data connection to the server,
113the server would use data ports in the range 1024..4999.  Now, by default,
114the server will use data ports in the range 40000..44999.  Specifying this
115option will revert to the old behavior.
116.It Fl T
117A client may also request a different timeout period;
118the maximum period allowed may be set to
119.Ar timeout
120seconds with the
121.Fl T
122option.
123The default limit is 2 hours.
124.It Fl t
125The inactivity timeout period is set to
126.Ar timeout
127seconds (the default is 15 minutes).
128.It Fl a
129When
130.Fl D
131is specified, accept connections only on the specified
132.Ar address .
133.It Fl p
134When
135.Fl D
136is specified, write the daemon's process ID to
137.Ar file .
138.It Fl A
139Allow only anonymous ftp access
140.El
141.Pp
142The file
143.Pa /etc/nologin
144can be used to disable ftp access.
145If the file exists,
146.Nm
147displays it and exits.
148If the file
149.Pa /etc/ftpwelcome
150exists,
151.Nm
152prints it before issuing the
153.Dq ready
154message.
155If the file
156.Pa /etc/ftpmotd
157exists,
158.Nm
159prints it after a successful login.
160.Pp
161The ftp server currently supports the following ftp requests.
162The case of the requests is ignored.
163.Bl -column "Request" -offset indent
164.It Request Ta "Description"
165.It ABOR Ta "abort previous command"
166.It ACCT Ta "specify account (ignored)"
167.It ALLO Ta "allocate storage (vacuously)"
168.It APPE Ta "append to a file"
169.It CDUP Ta "change to parent of current working directory"
170.It CWD Ta "change working directory"
171.It DELE Ta "delete a file"
172.It HELP Ta "give help information"
173.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA"
174.It MKD Ta "make a directory"
175.It MDTM Ta "show last modification time of file"
176.It MODE Ta "specify data transfer" Em mode
177.It NLST Ta "give name list of files in directory"
178.It NOOP Ta "do nothing"
179.It PASS Ta "specify password"
180.It PASV Ta "prepare for server-to-server transfer"
181.It PORT Ta "specify data connection port"
182.It PWD Ta "print the current working directory"
183.It QUIT Ta "terminate session"
184.It REST Ta "restart incomplete transfer"
185.It RETR Ta "retrieve a file"
186.It RMD Ta "remove a directory"
187.It RNFR Ta "specify rename-from file name"
188.It RNTO Ta "specify rename-to file name"
189.It SITE Ta "non-standard commands (see next section)"
190.It SIZE Ta "return size of file"
191.It STAT Ta "return status of server"
192.It STOR Ta "store a file"
193.It STOU Ta "store a file with a unique name"
194.It STRU Ta "specify data transfer" Em structure
195.It SYST Ta "show operating system type of server system"
196.It TYPE Ta "specify data transfer" Em type
197.It USER Ta "specify user name"
198.It XCUP Ta "change to parent of current working directory (deprecated)"
199.It XCWD Ta "change working directory (deprecated)"
200.It XMKD Ta "make a directory (deprecated)"
201.It XPWD Ta "print the current working directory (deprecated)"
202.It XRMD Ta "remove a directory (deprecated)"
203.El
204.Pp
205The following non-standard or
206.Tn UNIX
207specific commands are supported
208by the
209SITE request.
210.Pp
211.Bl -column Request -offset indent
212.It Sy Request Ta Sy Description
213.It UMASK Ta change umask, e.g. ``SITE UMASK 002''
214.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60''
215.It CHMOD Ta change mode of a file, e.g. ``SITE CHMOD 755 filename''
216.It HELP Ta give help information.
217.El
218.Pp
219The remaining ftp requests specified in Internet RFC 959
220are
221recognized, but not implemented.
222MDTM and SIZE are not specified in RFC 959, but will appear in the
223next updated FTP RFC.
224.Pp
225The ftp server will abort an active file transfer only when the
226ABOR
227command is preceded by a Telnet "Interrupt Process" (IP)
228signal and a Telnet "Synch" signal in the command Telnet stream,
229as described in Internet RFC 959.
230If a
231STAT
232command is received during a data transfer, preceded by a Telnet IP
233and Synch, transfer status will be returned.
234.Pp
235.Nm Ftpd
236interprets file names according to the
237.Dq globbing
238conventions used by
239.Xr csh 1 .
240This allows users to utilize the metacharacters
241.Dq Li \&*?[]{}~ .
242.Pp
243.Nm Ftpd
244authenticates users according to five rules.
245.Pp
246.Bl -enum -offset indent
247.It
248The login name must be in the password data base
249and not have a null password.
250In this case a password must be provided by the client before any
251file operations may be performed.
252If the user has an S/Key key, the response from a successful USER
253command will include an S/Key challenge. The client may choose to respond
254with a PASS command giving either a standard password or an S/Key
255one-time password. The server will automatically determine which type of
256password it has been given and attempt to authenticate accordingly. See
257.Xr key 1
258for more information on S/Key authentication. S/Key is a Trademark of
259Bellcore.
260.It
261The login name must not appear in the file
262.Pa /etc/ftpusers .
263.It
264The user must have a standard shell returned by
265.Xr getusershell 3 .
266.It
267If the user name appears in the file
268.Pa /etc/ftpchroot
269the session's root will be changed to the user's login directory by
270.Xr chroot 2
271as for an
272.Dq anonymous
273or
274.Dq ftp
275account (see next item).  However, the user must still supply a password.
276This feature is intended as a compromise between a fully anonymous account
277and a fully privileged account.  The account should also be set up as for an
278anonymous account.
279.It
280If the user name is
281.Dq anonymous
282or
283.Dq ftp ,
284an
285anonymous ftp account must be present in the password
286file (user
287.Dq ftp ) .
288In this case the user is allowed
289to log in by specifying any password (by convention an email address for
290the user should be used as the password).
291When the
292.Fl S
293option is set, all transfers are logged as well.
294.El
295.Pp
296In the last case,
297.Nm ftpd
298takes special measures to restrict the client's access privileges.
299The server performs a
300.Xr chroot 2
301to the home directory of the
302.Dq ftp
303user.
304In order that system security is not breached, it is recommended
305that the
306.Dq ftp
307subtree be constructed with care, following these rules:
308.Bl -tag -width "~ftp/pub" -offset indent
309.It Pa ~ftp
310Make the home directory owned by
311.Dq root
312and unwritable by anyone.
313.It Pa ~ftp/bin
314Make this directory owned by
315.Dq root
316and unwritable by anyone (mode 555).
317The program
318.Xr ls 1
319must be present to support the list command.
320This program should be mode 111.
321.It Pa ~ftp/etc
322Make this directory owned by
323.Dq root
324and unwritable by anyone (mode 555).
325The files pwd.db (see
326.Xr passwd 5 )
327and
328.Xr group 5
329must be present for the
330.Xr ls
331command to be able to produce owner names rather than numbers.
332The password field in
333.Xr passwd
334is not used, and should not contain real passwords.
335The file
336.Pa ftpmotd ,
337if present, will be printed after a successful login.
338These files should be mode 444.
339.It Pa ~ftp/pub
340Make this directory mode 777 and owned by
341.Dq ftp .
342Guests
343can then place files which are to be accessible via the anonymous
344account in this directory.
345.El
346.Sh FILES
347.Bl -tag -width /etc/ftpwelcome -compact
348.It Pa /etc/ftpusers
349List of unwelcome/restricted users.
350.It Pa /etc/ftpchroot
351List of normal users who should be chroot'd.
352.It Pa /etc/ftpwelcome
353Welcome notice.
354.It Pa /etc/ftpmotd
355Welcome notice after login.
356.It Pa /etc/nologin
357Displayed and access refused.
358.It Pa /var/log/ftpd
359Log file for anonymous transfers.
360.El
361.Sh SEE ALSO
362.Xr ftp 1 ,
363.Xr key 1 ,
364.Xr getusershell 3 ,
365.Xr inetd 8 ,
366.Xr syslogd 8
367.Sh BUGS
368The server must run as the super-user
369to create sockets with privileged port numbers.  It maintains
370an effective user id of the logged in user, reverting to
371the super-user only when binding addresses to sockets.  The
372possible security holes have been extensively
373scrutinized, but are possibly incomplete.
374.Sh HISTORY
375The
376.Nm
377command appeared in
378.Bx 4.2 .
379