xref: /freebsd/libexec/ftpd/ftpd.8 (revision 05c7a37afb48ddd5ee1bd921a5d46fe59cc70b15)
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.\"
34.Dd April 19, 1994
35.Dt FTPD 8
36.Os BSD 4.2
37.Sh NAME
38.Nm ftpd
39.Nd
40Internet File Transfer Protocol server
41.Sh SYNOPSIS
42.Nm ftpd
43.Op Fl dl
44.Op Fl D
45.Op Fl S
46.Op Fl U
47.Op Fl T Ar maxtimeout
48.Op Fl t Ar timeout
49.Sh DESCRIPTION
50.Nm Ftpd
51is the
52Internet File Transfer Protocol
53server process.  The server uses the
54.Tn TCP
55protocol
56and listens at the port specified in the
57.Dq ftp
58service specification; see
59.Xr services 5 .
60.Pp
61Available options:
62.Bl -tag -width Ds
63.It Fl d
64Debugging information is written to the syslog using LOG_FTP.
65.It Fl l
66Each successful and failed
67.Xr ftp 1
68session is logged using syslog with a facility of LOG_FTP.
69If this option is specified twice, the retrieve (get), store (put), append,
70delete, make directory, remove directory and rename operations and
71their filename arguments are also logged.
72.It Fl D
73With this option set,
74.Nm ftpd
75will detach and become a daemon, accepting connections on the FTP port and
76forking children processes to handle them. This is lower overhead than
77starting
78.Nm ftpd
79from
80.Xr inetd 8
81and is thus useful on busy servers to reduce load.
82.It Fl S
83With this option set,
84.Nm ftpd
85logs all anonymous transfers to the file
86.Pa /var/log/ftpd
87when this file exists.
88.
89.It Fl U
90In previous versions of
91.Nm ftpd ,
92when a passive mode client requested a data connection to the server,
93the server would use data ports in the range 1024..4999.  Now, by default,
94the server will use data ports in the range 40000..44999.  Specifying this
95option will revert to the old behavior.
96.It Fl T
97A client may also request a different timeout period;
98the maximum period allowed may be set to
99.Ar timeout
100seconds with the
101.Fl T
102option.
103The default limit is 2 hours.
104.It Fl t
105The inactivity timeout period is set to
106.Ar timeout
107seconds (the default is 15 minutes).
108.El
109.Pp
110The file
111.Pa /etc/nologin
112can be used to disable ftp access.
113If the file exists,
114.Nm
115displays it and exits.
116If the file
117.Pa /etc/ftpwelcome
118exists,
119.Nm
120prints it before issuing the
121.Dq ready
122message.
123If the file
124.Pa /etc/ftpmotd
125exists,
126.Nm
127prints it after a successful login.
128.Pp
129The ftp server currently supports the following ftp requests.
130The case of the requests is ignored.
131.Bl -column "Request" -offset indent
132.It Request Ta "Description"
133.It ABOR Ta "abort previous command"
134.It ACCT Ta "specify account (ignored)"
135.It ALLO Ta "allocate storage (vacuously)"
136.It APPE Ta "append to a file"
137.It CDUP Ta "change to parent of current working directory"
138.It CWD Ta "change working directory"
139.It DELE Ta "delete a file"
140.It HELP Ta "give help information"
141.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA"
142.It MKD Ta "make a directory"
143.It MDTM Ta "show last modification time of file"
144.It MODE Ta "specify data transfer" Em mode
145.It NLST Ta "give name list of files in directory"
146.It NOOP Ta "do nothing"
147.It PASS Ta "specify password"
148.It PASV Ta "prepare for server-to-server transfer"
149.It PORT Ta "specify data connection port"
150.It PWD Ta "print the current working directory"
151.It QUIT Ta "terminate session"
152.It REST Ta "restart incomplete transfer"
153.It RETR Ta "retrieve a file"
154.It RMD Ta "remove a directory"
155.It RNFR Ta "specify rename-from file name"
156.It RNTO Ta "specify rename-to file name"
157.It SITE Ta "non-standard commands (see next section)"
158.It SIZE Ta "return size of file"
159.It STAT Ta "return status of server"
160.It STOR Ta "store a file"
161.It STOU Ta "store a file with a unique name"
162.It STRU Ta "specify data transfer" Em structure
163.It SYST Ta "show operating system type of server system"
164.It TYPE Ta "specify data transfer" Em type
165.It USER Ta "specify user name"
166.It XCUP Ta "change to parent of current working directory (deprecated)"
167.It XCWD Ta "change working directory (deprecated)"
168.It XMKD Ta "make a directory (deprecated)"
169.It XPWD Ta "print the current working directory (deprecated)"
170.It XRMD Ta "remove a directory (deprecated)"
171.El
172.Pp
173The following non-standard or
174.Tn UNIX
175specific commands are supported
176by the
177SITE request.
178.Pp
179.Bl -column Request -offset indent
180.It Sy Request Ta Sy Description
181.It UMASK Ta change umask, e.g. ``SITE UMASK 002''
182.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60''
183.It CHMOD Ta change mode of a file, e.g. ``SITE CHMOD 755 filename''
184.It HELP Ta give help information.
185.El
186.Pp
187The remaining ftp requests specified in Internet RFC 959
188are
189recognized, but not implemented.
190MDTM and SIZE are not specified in RFC 959, but will appear in the
191next updated FTP RFC.
192.Pp
193The ftp server will abort an active file transfer only when the
194ABOR
195command is preceded by a Telnet "Interrupt Process" (IP)
196signal and a Telnet "Synch" signal in the command Telnet stream,
197as described in Internet RFC 959.
198If a
199STAT
200command is received during a data transfer, preceded by a Telnet IP
201and Synch, transfer status will be returned.
202.Pp
203.Nm Ftpd
204interprets file names according to the
205.Dq globbing
206conventions used by
207.Xr csh 1 .
208This allows users to utilize the metacharacters
209.Dq Li \&*?[]{}~ .
210.Pp
211.Nm Ftpd
212authenticates users according to three rules.
213.Pp
214.Bl -enum -offset indent
215.It
216The login name must be in the password data base,
217.Pa /etc/passwd ,
218and not have a null password.
219In this case a password must be provided by the client before any
220file operations may be performed.
221.It
222The login name must not appear in the file
223.Pa /etc/ftpusers .
224.It
225The user must have a standard shell returned by
226.Xr getusershell 3 .
227.It
228If the user name is
229.Dq anonymous
230or
231.Dq ftp ,
232an
233anonymous ftp account must be present in the password
234file (user
235.Dq ftp ) .
236In this case the user is allowed
237to log in by specifying any password (by convention an email address for
238the user should be used as the password). When the
239.Fl S
240option is set, all transfers are logged as well.
241.El
242.Pp
243In the last case,
244.Nm ftpd
245takes special measures to restrict the client's access privileges.
246The server performs a
247.Xr chroot 2
248to the home directory of the
249.Dq ftp
250user.
251In order that system security is not breached, it is recommended
252that the
253.Dq ftp
254subtree be constructed with care, following these rules:
255.Bl -tag -width "~ftp/pub" -offset indent
256.It Pa ~ftp
257Make the home directory owned by
258.Dq root
259and unwritable by anyone.
260.It Pa ~ftp/bin
261Make this directory owned by
262.Dq root
263and unwritable by anyone (mode 555).
264The program
265.Xr ls 1
266must be present to support the list command.
267This program should be mode 111.
268.It Pa ~ftp/etc
269Make this directory owned by
270.Dq root
271and unwritable by anyone (mode 555).
272The files
273.Xr passwd 5
274and
275.Xr group 5
276must be present for the
277.Xr ls
278command to be able to produce owner names rather than numbers.
279The password field in
280.Xr passwd
281is not used, and should not contain real passwords.
282The file
283.Pa ftpmotd ,
284if present, will be printed after a successful login.
285These files should be mode 444.
286.It Pa ~ftp/pub
287Make this directory mode 777 and owned by
288.Dq ftp .
289Guests
290can then place files which are to be accessible via the anonymous
291account in this directory.
292.El
293.Sh FILES
294.Bl -tag -width /etc/ftpwelcome -compact
295.It Pa /etc/ftpusers
296List of unwelcome/restricted users.
297.It Pa /etc/ftpwelcome
298Welcome notice.
299.It Pa /etc/ftpmotd
300Welcome notice after login.
301.It Pa /etc/nologin
302Displayed and access refused.
303.It Pa /var/log/ftpd
304Log file for anonymous transfers.
305.El
306.Sh SEE ALSO
307.Xr ftp 1 ,
308.Xr getusershell 3 ,
309.Xr inetd 8 ,
310.Xr syslogd 8
311.Sh BUGS
312The server must run as the super-user
313to create sockets with privileged port numbers.  It maintains
314an effective user id of the logged in user, reverting to
315the super-user only when binding addresses to sockets.  The
316possible security holes have been extensively
317scrutinized, but are possibly incomplete.
318.Sh HISTORY
319The
320.Nm
321command appeared in
322.Bx 4.2 .
323