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