ftpd is the Internet File Transfer Protocol
server process.
The server uses the TCP protocol
and listens at the port specified in the FTP
service specification; see
services(4tcp).
ftpd understands the following options:
-a
Enable the use of the ftpaccess configuration file.
-A
Disable the use of the ftpaccess configuration file (default).
-d
Write debugging information to the syslog file.
Equivalent to -v.
-i
Log files received by the
ftpd server to the xferlog file.
-l
Log each FTP session in the syslog file.
-L
Log commands sent to the ftpd server to the syslog file.
Commands are logged as soon as the FTP server is invoked.
This will cause the server to log all USER
commands. If a user accidentally enters a
password for that command instead of the
username, the password will be logged in syslog.
-o
Log files transmitted by the
ftpd server to the xferlog file.
-ttimeout
Set the inactivity timeout period to timeout seconds.
By default,
the FTP server will timeout an inactive session
after 900 seconds (15 minutes).
-Ttimeout
Set the maximum timeout period that
a client may request.
The default limit is 7200 seconds (2 hours).
-uumask
Set the default file-creation mode mask to umask (an octal integer).
-v
Write debugging information to the syslog file.
Equivalent to -d.
The -i, -L and -o options are
overridden by the use of the ftpaccess file.
The FTP server currently supports the following FTP
requests; case (lower or upper) is not distinguished.
ABOR
abort previous command
ACCT
specify account (ignored)
ALLO
allocate storage (vacuously)
APPE
append to a file
CDUP
change to parent of current working directory
CWD
change working directory
DELE
delete a file
HELP
give help information
LIST
give list files in a directory (ls -lgA)
MKD
make a directory
MDTM
show last modification time of file
MODE
specify data transfer mode
NLST
give name list of files in directory
NOOP
do nothing
PASS
specify password
PASV
prepare for server-to-server transfer
PORT
specify data connection port
PWD
print the current working directory
QUIT
terminate session
REST
restart incomplete transfer
RETR
retrieve a file
RMD
remove a directory
RNFR
specify rename-from file name
RNTO
specify rename-to file name
SITE
non-standard commands (see next section)
SIZE
return size of file
STAT
return status of server
STOR
store a file
STOU
store a file with a unique name
STRU
specify data transfer structure
SYST
show operating system type of server system
TYPE
specify data transfer type
USER
specify user name
XCUP
change to parent of current working directory (deprecated)
XCWD
change working directory (deprecated)
XMKD
make a directory (deprecated)
XPWD
print the current working directory (deprecated)
XRMD
remove a directory (deprecated)
The following non-standard or UNIX specific commands are supported
by the SITE request:
ALIAS
list aliases (which only apply to the cd command)
CDPATH
list the search path used when changing directory
CHMOD
change mode of a file, for example: SITE CHMOD 755filename
EXEC
execute a program,
for example: SITE EXECprogramparams
GPASS
give special group access password, for example: SITE GPASS bar
GROUP
request special group access, for example: SITE GROUP foo
GROUPS
list supplemental group membership
HELP
give help information, for example: SITE HELP
IDLE
set idle-timer, for example: SITE IDLE 60
INDEX
execute a local index command
LANG
change the language which the ftpd
server uses to send messages to the client.
When ftp establishes a connection,
the value of LANG
(if set in the environment)
is passed to ftpd
using the SITE LANG command
MINFO
like SITE NEWER, but gives extra information
NEWER
list files newer than a particular date
UMASK
change umask, for example: SITE UMASK 002
The remaining FTP requests specified in
RFC 959 are recognized, but not implemented.
MDTM and SIZE are not specified in
RFC 959, but will appear in the next updated
FTP RFC.
The FTP server will abort an active file transfer only when the
ABOR command is preceded by a Telnet "Interrupt Process" (IP)
signal and a Telnet "Synch" signal in the command Telnet stream,
as described in Internet RFC 959.
If a STAT command is received during a data transfer, preceded by a Telnet IP
and Synch, transfer status will be returned.
ftpd
interprets file names according to the ``globbing''
conventions used by
csh(1).
This allows users to utilize the metacharacters ``*?[]{}~''.
ftpd authenticates users according to four rules:
The user name must be in the password data base,
/etc/passwd,
and the password must not be null. In this case a password
must be provided by the client before any file operations
may be performed.
The user name must not appear in the file
/etc/ftpusers. A user name of anonymous or
ftp prevents anonymous FTP access.
Users other than the anonymous FTP user
must have a standard shell (one listed in /etc/shells).
If the user name is anonymous or ftp, an
anonymous FTP account must be present in the password
file (user ftp). In this case the user is allowed
to log in by specifying any password (by convention this
is given as the client host's name).
WARNING:
Ensure that the anonymous FTP account cannot be
used to log into your system other than via FTP.
Lock the account using the -l option to
passwd(1)
and give the account an invalid login shell such as /bin/true.
In the last case,
ftpd
takes special measures to restrict the client's access privileges.
The server performs a
chroot(2)
command to the home directory of the ftp user.
In order that system security is not breached, it is recommended
that the FTP subtree be constructed with care; the following
rules are recommended:
~ftp
Make the home directory owned by root and unwritable by anyone
(mode 555).
~ftp/bin
Make this directory owned by root and executable but unreadable
and unwritable by anyone (mode 111).
The program ls(1)
must be present to support the list command. This
program should have mode 111.
~ftp/dev
Make this directory owned by root and executable but unreadable
and unwritable by anyone (mode 111). Copy in the tcp
and zero devices
by executing the following command as root:
ls /dev/tcp /dev/zero | cpio -p ~ftp
~ftp/etc
Make this directory owned by root and executable but unreadable
and unwritable by anyone (mode 111).
Copy /etc/netconfig to this directory.
Create passwd and group files from scratch.
These files must be present for the ls command to be
able to produce owner and group names rather than numbers.
The passwd and group files should only
contain entries corresponding to the owner/group of files under
the anonymous FTP hierarchy (for example,
root and ftp). Home directory pathnames
and login shells need not be specified, and the password field should be
left empty.
These files should have mode 444 and
be owned by root.
~ftp/pub
Make this directory owned by root and readable and executable
by all users (mode 555).
~ftp/pub/incoming
If you want to allow anonymous users to upload files, create this directory
owned by root with mode 1777. If you want to discourage
abusers, set a mode of 1733 to make the directory unreadable.
Note that the sticky bit is set to limit who is able to remove or rename
files (see
chmod(2)).
~ftp/usr
Make this directory owned by root and executable but unreadable
and unwritable by anyone (mode 111).
~ftp/usr/lib
Make this directory owned by root and executable but unreadable
and unwritable by anyone (mode 111). The library libc.so.1
must be present to support the list command.
Copy the library from /usr/lib, and set the owner to
root and the mode to 111.
General FTP extensions
Certain actions may be performed on the file when carrying
out the RETR command,
depending on how the destination filename is named.
Note that these actions are controlled by the
ftpconversions(4tcp)
file and the
tar and compress keywords in the
ftpaccess(4tcp)
file.
The request will fail if the filename to be tar'ed
is a directory containing a file named .notar.
Original
Destination
Action
filename.Z
filename
Decompress filename before transmitting
filename
filename.Z
Compress filename before transmitting
filename
filename.tar
Tar filename before transmitting
filename
filename.tar.Z
Tar and compress filename before transmitting
For anonymous and guest users to be able to use these extensions, any
commands listed in the
ftpconversions(4tcp)
file and any associated dynamic objects (determined using
ldd(1))
must be present in the appropriate location
under the anonymous and guest user's home directory hierarchy.
Commands should normally have mode 111, and dynamic objects (with the
exception of libc.so.1) mode 444.
Depending on the arguments to the passwd-check keyword
in the ftpaccess file,
the FTP server may attempt to check whether
an anonymous user has supplied a valid
e-mail address as their password.
If a user's FTP client
hangs on ``long replies'' (responses consisting of multiple lines),
they should use a dash as the first character of the password
to stop the server sending continuation messages.
The FTP server can also log all file transmission and reception
with the format described in
xferlog(4tcp).
Files
/bin/ftp-exec
directory containing executables run by the EXEC command
The anonymous account is inherently dangerous and should be
avoided when possible.
The server must run as root
to create sockets with privileged port numbers. It maintains
an effective user ID of the logged in user, reverting to
root only when binding addresses to sockets. The
possible security holes have been extensively
scrutinized, but are possibly incomplete.