pure-ftpd - simple File Transfer Protocol server
Contents
Anonymous Ftp
This server leaves out some of the commands and features that have been used to subvert anonymous FTP
servers in the past, but still you have to be a little bit careful in order to support anonymous FTP
without risk to the rest of your files.
Make ~ftp and all files and directories below this directory owned by some user other than "ftp," and
only the .../incoming directory/directories writable by "ftp." It is probably best if all directories are
writable only by a special group such as "ftpadmin" and "ftp" is not a member of this group.
If you do not trust the local users, put ~ftp on a separate partition, so local users can't hard-link
unapproved files into the anonymous FTP area.
Use of the -s option is strongly suggested. (Simply add "-s" to the end of the ftpd line in
/etc/inetd.conf to enable it.)
Most other FTP servers require that a number of files such as ~ftp/bin/ls exist. This server does not
require that any files or directories within ~/ftp whatsoever exist, and I recommend that all such
unnecessary files are removed (for no real reason).
It may be worth considering to run the anonymous FTP service as a virtual server, to get automatic logins
and to firewall off the FTP address/port to which real users can log in.
If your server is a public FTP site, you may want to allow only 'ftp' and 'anonymous' users to log in.
Use the -e option for this. Real accounts will be ignored and you will get a secure, anonymous-only FTP
server.
Authentication
Some of the complexities of older servers are left out.
This version of pure-ftpd can use PAM for authentication. If you want it to consult any files like
/etc/shells or /etc/ftpd/ftpusers consult pam docs. LDAP directories and SQL databases are also
supported.
Anonymous users are authenticated in any of three ways:
1. The user logs in as "ftp" or "anonymous" and there is an account called "ftp" with an existing home
directory. This server does not ask anonymous users for an email address or other password.
2. The user connects to an IP address which resolves to the name of a directory in /etc/pure-ftpd/pure-ftpd (or a symlink in that directory to a real directory), and there is an account called "ftp"
(which does not need to have a valid home directory). See VirtualServers below.
Ftpd does a chroot(2) to the relevant base directory when an anonymous user logs in.
Note that ftpd allows remote users to log in as root if the password is known and -u not used.
Bugs
Please report bugs to the mailing-list (see below). Pure-FTPd looks very stable and is used on
production servers. However it comes with no warranty and it can have nasty bugs or security flaws.
Description
Pure-FTPd is a small, simple server for the old and hairy File Transfer Protocol, designed to use less
resources than older servers, be smaller and very secure, and to never execute any external program.
It support most-used features and commands of FTP (including many modern extensions), and leaves out
everything which is deprecated, meaningless, insecure, or correlates with trouble.
IPv6 is fully supported.
Directory Aliases
Shortcuts for the "cd" command can be set up if the server has been compiled with the --with-diraliases
feature.
To enable directory aliases, create a file called /etc/pure-ftpd/pureftpd-dir-aliases and alternate lines
of alias names and associated directories.
Files
/etc/passwd is used via libc (and PAM is this case), to get the uid and home directory of normal users, the uid and home directory of "ftp" for normal anonymous ftp, and just the uid of "ftp" for virtual ftp hosts. /etc/shadow is used like /etc/passwd if shadow support is enabled. /etc/group is used via libc, to get the group membership of normal users. /proc/net/tcp is used to count existing FTP connections, if the -c or -p options are used /etc/pure-ftpd/pure-ftpd/<ipaddress> is the base directory for the <ip address> virtual ftp server, or a symbolic link to its base directory. Ftpd does a chroot(2) into this directory when a user logs in to <ip address>, thus symlinks outside this directory will not work. ~ftp is the base directory for "normal" anonymous FTP. Ftpd does a chroot(2) into this directory when an anonymous user logs in, thus symlinks outside this directory will not work.
Home Page
Ls
The behaviour of LIST and NLST is a tricky issue. Few servers send RFC-compliant responses to LIST, and
some clients depend on non-compliant responses.
This server uses glob(3) to do filename globbing.
The response to NLST is by default similar to that of ls(1), and that to LIST is by default similar to
that of ls-l or ls-lg on most Unix systems, except that the "total" count is meaningless. Only regular
files, directories and symlinks are shown. Only important ls options are supported:
-1 Undoes -l and -C.
-a lists even files/directories whose names begin with ".".
-C lists files in as many colums as will fit on the screen. Undoes -1 and -l.
-d lists argument directories' names rather their contents.
-D List files beginning with a dot ('.') even when the client doesn't append the -a option to the
list command.
-F appends '*' to executable regular files, '@' to symlinks and '/' to directories.
-l shows various details about the file, including file group. See ls(1) for details. Undoes -1 and
-C.
-r reverses the sorting order (modifies -S and -t and the default alphabetical ordering).
-R recursively descends into subdirectories of the argument directories.
-S Sorts by file size instead of by name. Undoes -t.
-t Sorts by file modification time instead of by name. Undoes -S.
Magic Files
The files <ftproot>/.banner and .message are magical.
If there is a file called .banner in the root directory of the anonymous FTP area, or in the root
directory of a virtual host, and it is shorter than 1024 bytes, it is printed upon login. (If the client
does not log in explicitly, and an implicit login is triggered by a CWD or CDUP command, the banner is
not printed. This is regrettable but hard to avoid.)
If there is a file called .message in any directory and it is shorter than 1024 bytes, that file is
printed whenever a user enters that directory using CWD or CDUP.
Name
pure-ftpd - simple File Transfer Protocol server
New Versions
See the mailing-list on http://www.pureftpd.org/ml/.
Options
-0 When a file is uploaded and there is already a previous version of the file with the same name,
the old file will neither get removed nor truncated. Upload will take place in a temporary file
and once the upload is complete, the switch to the new version will be atomic. This option should
not be used together with virtual quotas.
-1 Add the PID to the syslog output. Ignored if -fnone is set.
-2cert_file[,key_file]
When using TLS, set the path to the certificate file. The certificate and its key can be be
bundled into a single file, or the key can be in a distinct file.
-3path
Path to the pure-certd UNIX socket.
-4 Listen only to IPv4 connections.
-6 Listen only to IPv6 connections.
-agid Regular users will be chrooted to their home directories, unless they belong to the specified gid.
Note that root is always trusted, and that chroot() occurs only for anonymous ftp without this
option.
-A Chroot() everyone, but root.
-b Be broken. Turns on some compatibility hacks for shoddy clients, and for broken Netfilter
gateways.
-B Start the standalone server in background (daemonize).
-cclients
Allow a maximum of clients to be connected. clients must be at least 1, and if you combine it
with -p it will be forced down to half the number of ports specified by -p. If more than clients
are connected, new clients are rejected at once, even clients wishing to upload, or to log in as
normal users. Therefore, it is advisable to use -m as primary overload protection. The default
value is 50.
-Cmaxconnectionperip
Limit the number of simultaneous connections coming from the same IP address. This is yet another
very effective way to prevent stupid denial of services and bandwidth starvation by a single user.
It works only when the server is launched in standalone mode (if you use a super-server, it is
supposed to do that). If the server is launched with -C2 , it doesn't mean that the total number
of connection is limited to 2. But the same client, coming from the same machine (or at least the
same IP), can't have more than two simultaneous connections. This features needs some memory to
track IP addresses, but it's recommended to use it.
-d turns on debug logging. Every command is logged, except that the argument to PASS is changed to
"<password>". If you repeat -d , responses too are logged.
-e Only allow anonymous users to log in.
-E Only allow authenticated login. Anonymous users are prohibited.
-ffacility
makes ftpd use facility for all syslog(3) messages. facility defaults to ftp. The facility names
are normally listed in /usr/include/sys/syslog.h. Note that if -f is not the first option on the
command line, a couple of messages may be logged to local2 before the -f option is parsed. Use -fnone to disable logging.
-Ffortunesfile
Display a funny random message in the initial login banner. The random cookies are extracted from
a text file, in the standard fortune format. If you installed the fortune package, you should have
a directory (usually /usr/share/fortune ) with binary files ( xxxx.dat ) and text files (without
the .dat extension).
-gpidfile
In standalone mode, write the pid to that file in instead of /var/run/pure-ftpd.pid .
-G When this option is enabled, people can no more change the name of already uploaded files, even if
they own those files or their directory.
-H Don't resolve host names ("192.0.34.166" will be logged instead of "www.example.com"). It can
significantly speed up connections and reduce bandwidth usage on busy servers. Use it especially
on public FTP sites.
-i Disallow upload for anonymous users, whatever directory permissions are. This option is especially
useful for virtual hosting, to avoid your users create warez sites in their account.
-Itimeout
Change the maximum idle time. The timeout is in minutes, and defaults to 15.
-j If the home directory of a user doesn't exist, automatically create it. The newly created home
directory belongs to the user, and permissions are set according to the current directory mask. To
avoid local attacks, the parent directory should never belong to an untrusted user.
-Jciphers
Set the list of ciphers that will be accepted for TLS connections.
-kpercentage
Disallow upload if the partition is more than percentage full. Example: -k 95 will ensure that
your disk will never get filled more than 95% by FTP users.
-K Allow users to resume and upload files, but NOT to delete them. Directories can be removed, but
only if they are empty.
-lauthentication:file
Enable a new authentication method. It can be one of: -lunix For standard (/etc/passwd)
authentication. -lpam For PAM authentication. -lldap:LDAPconfigfile For LDAP directories.
-lmysql:MySQLconfigfile For MySQL databases. -lpgsql:Postgresconfigfile For Postgres
databases. -lpuredb:PureDBdatabasefile For PureDB databases. -lextauth:pathtopure-authdsocket For external authentication handlers.
Different authentication methods can be mixed together. For instance if you run the server with
-lpuredb:/etc/pure-ftpd/pwd.pdb-lmysql:/etc/pure-ftpd/my.cf-lunix Accounts will first be
authenticated from a PureDB database. If it fails, a MySQL server will be asked. If the account is
still not found is the database, standard unix accounts will be scanned. Authentication methods
are tried in the order you give the -l options, if you do not give -l, then the decision comes
from configure, if PAM is built in, it is used, if not, then UNIX (/etc/passwd) is used by
default.
See the README.LDAP and README.MySQL files for info about the built-in LDAP and SQL directory
support.
-Lmaxfiles:maxdepth
Avoid denial-of-service attacks by limiting the number of displayed files in a 'ls' and the
maximum depth of a recursive 'ls'. Defaults are 2000:5 (2000 files displayed for a single 'ls' and
walk through 5 subdirectories max).
-mload
Do not allow anonymous users to download files if the load is above load when the user connects.
Uploads and file listings are still allowed, as are downloads by real users. The user is not told
about this until he/she tries to download a file.
-M Allow anonymous users to create directories.
-nmaxfiles:maxsize
Enable virtualquotas When virtual quotas are enabled, .ftpquota files are created, and the number
of files for a user is restricted to 'maxfiles'. The max total size of his directory is also
restricted to 'maxsize' Megabytes. Members of the trusted group aren't subject to quotas.
-N NAT mode. Force active mode. If your FTP server is behind a NAT box that doesn't support
applicative FTP proxying, or if you use port redirection without a transparent FTP proxy, use
this. Well... the previous sentence isn't very clear. Okay: if your network looks like this:
FTP--NAT.gateway/router--Internet
and if you want people coming from the internet to have access to your FTP server, please try
without this option first. If Netscape clients can connect without any problem, your NAT gateway
rulez. If Netscape doesn't display directory listings, your NAT gateway sucks. Use -N as a
workaround.
-o Enable pure-uploadscript.
-Oformat:logfile
Record all file transfers into a specific log file, in an alternative format. Currently, three
formats are supported: CLF, Stats, W3C and xferlog.
If you add
-Oclf:/var/log/pureftpd.log
to your starting options, Pure-FTPd will log transfers in /var/log/pureftpd.log in a format
similar to the Apache web server in default configuration.
If you add
-Ostats:/var/log/pureftpd.log
to your starting options, Pure-FTPd will create accurate log files designed for traffic analys
software like ftpStats.
If you add
-Ow3c:/var/log/pureftpd.log
to your starting options, Pure-FTPd will create W3C-conformant log files.
For security purposes, the path must be absolute (eg. /var/log/pureftpd.log, not
../log/pureftpd.log).
-pfirst:last
Use only ports in the range first to last inclusive for passive-mode downloads. This means that
clients will not try to open connections to TCP ports outside the range first-last, which makes
pure-ftpd more compatible with packet filters. Note that the maximum number of clients (specified
with -c) is forced down to (last+1-first)/2 if it is greater, as the default is. (The syntax
for the port range is, conveniently, the same as that of iptables).-Pipaddressorhostname
Force the specified IP address in reply to a PASV/EPSV command. If the server is behind a
masquerading (NAT) box that doesn't properly handle stateful FTP masquerading, put the ip address
of that box here. If you have a dynamic IP address, you can use a symbolic host name (probably the
one of your gateway), that will be resolved every time a new client will connect.
-qupload:download
Enable an upload/download ratio for anonymous users (ex: -q1:5 means that 1 Mb of goodies have to
be uploaded to leech 5 Mb).
-Qupload:download
Enable ratios for anonymous and non-anonymous users. If the -a option is also used, users from the
trusted group have no ratio.
-r Never overwrite existing files. Uploading a file whose name already exists cause an automatic
rename. Files are called xyz.1, xyz.2, xyz.3, etc.
-R Disallow users (even non-anonymous ones) usage of the CHMOD command. On hosting services, it may
prevent newbies from doing mistakes, like setting bad permissions on their home directory. Only
root can use CHMOD when this switch is enabled.
-s Don't allow anonymous users to retrieve files owned by "ftp" (generally, files uploaded by other
anonymous users).
-S[{ipaddress|hostname}][,{port|servicename}]
This option is only effective when the server is launched as a standalone server. Connections are
accepted on the specified IP and port. IPv4 and IPv6 are supported. Numeric and fully-qualified
host names are accepted. A service name (see /etc/services) can be used instead of a numeric port
number.
-tbandwidth
or -tuploadbandwidth:downloadbandwidth Enable process priority lowering and bandwidth
throttling for anonymous users. Delay should be in kilobytes/seconds.
-Tbandwidth
or -Tuploadbandwidth:downloadbandwidth Enable process priority lowering and bandwidth
throttling for *ALL* users. Pure-FTPd should have been explicitly compiled with throttling
support to have these flags work. It is possible to have different bandwidth limits for uploads
and for downloads. '-t' and '-T' can indeed be followed by two numbers delimited by a column
(':'). The first number is the upload bandwidth and the next one applies only to downloads. One of
them can be left blank which means infinity. A single number without any column means that the
same limit applies to upload and download.
-uuid Do not allow uids below uid to log in (typically, low-numbered uids are used for administrative
accounts). -u100 is sufficient to deny access to all administrative accounts on many linux
boxes, where 99 is the last administrative account. Anonymous FTP is allowed even if the uid of
the ftp user is smaller than uid. -u1 denies access only to root accounts. The default is to
allow FTP access to all accounts.
-Uumaskfiles:umaskdirs
Change the mask for creation of new files and directories. The default are 133 (files are readable
-but not writable- by other users) and 022 (same thing for directory, with the execute bit on).
If new files should only be readable by the user, use 177:077. If you want uploaded files to be
executable, use 022:022 (files will be readable by other people) or 077:077 (files will only be
readable by their owner).
-vbonjourname
Set the Bonjour name of the service (only available on MacOS X when Bonjour support is compiled
in).
-Vipaddress
Allow non-anonymous FTP access only on this specific local IP address. All other IP addresses are
only anonymous. With that option, you can have routed IPs for public access, and a local IP (like
10.x.x.x) for administration. You can also have a routable trusted IP protected by firewall rules,
and only that IP can be used to login as a non-anonymous user.
-w Enable support for the FXP protocol, for non-anonymous users only.
-W Enable the FXP protocol for everyone. FXPISANUNSECUREPROTOCOL.NEVERENABLEITONUNTRUSTEDNETWORKS.-x In normal operation mode, authenticated users can read/write files beginning with a dot ('.').
Anonymous users can't, for security reasons (like changing banners or a forgotten .rhosts). When
'-x' is used, authenticated users can download dot-files, but not overwrite/create them, even if
they own them. That way, you can prevent hosted users from messing .qmail files.
-X This flag is identical to the previous one (writing dot-files is prohibited), but in addition,
users can't even *read* files and directories beginning with a dot (like "cd .ssh").
-yperusermaxsessions:maxanonymoussessions
This switch enables per-user concurrency limits. Two values are separated by a column. The first
one is the max number of concurrent sessions for a single login. The second one is the maximum
number of anonoymous sessions.
-Ytlsbehavior-Y0 (default) disables TLS security mechanisms.
-Y1 Accept both normal sessions and TLS ones.
-Y2 refuses connections that aren't using TLS security mechanisms, including anonymous ones.
-Y3 refuses connections that aren't using TLS security mechanisms, and refuse cleartext data
channels as well.
The server must have been compiled with TLS support and a valid certificate must be in place to
accept encrypted sessions.
-z Allow anonymous users to read files and directories starting with a dot ('.').
-Z Add safe guards against common customer mistakes (like chmod 0 on their own files) .
Protocol
Here are the FTP commands supported by this server.
ABORALLOAPPEAUTHTLSCCCCDUPCWDDELEEPRTEPSVESTAESTPFEATHELPLISTMDTMMFMTMKDMLSDMLSTMODENLSTNOOPPASSPASVPBSZPORTPROTPWDQUITRESTRETRRMDRNFRRNTOSIZESTATSTORSTOUSTRUSYSTTYPEUSERXCUPXCWDXDBGXMKDXPWDXRMDOPTSMLSTSITECHMODSITEHELPSITEIDLESITETIMESITEUTIMESee Also
ftp(1), pure-ftpd(8)pure-ftpwho(8)pure-mrtginfo(8)pure-uploadscript(8)pure-statsdecode(8)pure-pw(8)pure-quotacheck(8)pure-authd(8)pure-certd(8)RFC959, RFC2228, RFC2389, RFC2428 and RFC4217. Frank Denis 1.0.50 pure-ftpd(8)
Synopsis
pure-ftpd[-0][-1][-2cert_file[,key_file]][-3certd_socket][-4][-6][-agid][-A][-b][-B][-cclients][-Ccnx/ip][-d[-d]][-D][-e][-E][-ffacility][-Ffortunesfile][-gpidfile][-G][-H][-i][-I][-j][-Jciphers][-kpercentage][-K][-lauthentication[:configfile]][-Lmaxfiles:maxdepth][-mmaxload][-M][-nmaxfiles:maxsize][-N][-o][-Oformat:logfile][-pfirst:last][-Pipaddressorhostname][-qupload:downloadratio][-Qupload:downloadratio][-r][-R][-s][-S[address,][port]][-tuploadbandwidth:downloadbandwidth][-Tuploadbandwidth:downloadbandwidth][-uuid][-Uumaskfiles:umaskdirs][-vbonjourname][-Vipaddress][-w][-W][-x][-X][-ymaxusersessions:maxanonsessions][-Ytlsbehavior][-z][-Z]
Alternative style:
-0 --notruncate
-1 --logpid
-2 --certfile
-3 --extcert
-4 --ipv4only
-6 --ipv6only
-a --trustedgid
-A --chrooteveryone
-b --brokenclientscompatibility
-B --daemonize
-c --maxclientsnumber
-C --maxclientsperip
-d --verboselog
-D --displaydotfiles
-e --anonymousonly
-E --noanonymous
-f --syslogfacility
-F --fortunesfile
-g --pidfile
-G --norename
-h --help
-H --dontresolve
-i --anonymouscantupload
-I --maxidletime
-j --createhomedir
-J --tlsciphersuite
-k --maxdiskusagepct
-K --keepallfiles
-l --login
-L --limitrecursion
-m --maxload
-M --anonymouscancreatedirs
-n --quota
-N --natmode
-o --uploadscript
-O --altlog
-p --passiveportrange
-P --forcepassiveip
-q --anonymousratio
-Q --userratio
-r --autorename
-R --nochmod
-s --antiwarez
-S --bind
-t --anonymousbandwidth
-T --userbandwidth
-u --minuid
-U --umask
-v --bonjour
-V --trustedip
-w --allowuserfxp
-W --allowanonymousfxp
-x --prohibitdotfileswrite
-X --prohibitdotfilesread
-y --peruserlimits
-Y --tls
-z --allowdotfiles
-Z --customerproof
Unusual Features
If a user's home directory is /path/to/home/./, FTP sessions under that UID will be chroot()ed. In
addition, if a users's home directory is /path/to/home/./directory the session will be chroot()ed to
/path/to/home and the FTP session will start in 'directory'.
As noted above, this pure-ftpd omits several features that are required by the RFC or might be considered
useful at first. Here is a list of the most important omissions.
On-the-fly tar is not supported, for several reasons. I feel that users who want to get many files should
use a special FTP client such as "mirror," which also supports incremental fetch. I don't want to either
add several hundred lines of code to create tar files or execute an external tar. Finally, on-the-fly tar
distorts log files.
On-the-fly compression is left out too. Most files on an FTP site are compressed already, and if a file
isn't, there presumably is a reason why. (As for decompression: Don't FTP users waste bandwidth enough
without help from on-the-fly decompression?)
Virtual Servers
You can run several different anonymous FTP servers on one host, by giving the host several IP addresses
with different DNS names.
Here are the steps needed to create an extra server using an IP alias on linux 2.4.x, called
"ftp.example.com" on address 10.11.12.13. on the IP alias eth0.
1. Create an "ftp" account if you do not have one. It it best if the account does not have a valid home
directory and shell. I prefer to make /dev/null the ftp account's home directory and shell. Ftpd uses
this account to set the anonymous users' uid.
2. Create a directory as described in AnonymousFTP and make a symlink called /etc/pure-ftpd/pure-ftpd/10.11.12.13 which points to this directory.
3. Make sure your kernel has support for IP aliases.
4. Make sure that the following commands are run at boot:
/sbin/ifconfig eth0:1 10.11.12.13
That should be all. If you have problems, here are some things to try.
First, symlink /etc/pure-ftpd/pure-ftpd/127.0.0.1 to some directory and say "ftp localhost". If that
doesn't log you in, the problem is with ftpd.
If not, "ping -v 10.11.12.13" and/or "ping -v ftp.example.com" from the same host. If this does not work,
the problem is with the IP alias.
Next, try "ping -v 10.11.12.13" from a host on the local ethernet, and afterwards "/sbin/arp -a". If
10.11.12.13 is listed among the ARP entries with the correct hardware address, the problem is probably
with the IP alias. If 10.11.12.13 is listed, but has hardware address 0:0:0:0:0:0, then proxy-ARP isn't
working.
If none of that helps, I'm stumped. Good luck.
Warning: If you setup a virtual hosts, normal users will not be able to login via this name, so don't
create link/directory in /etc/pure-ftpd/pure-ftpd for your regular hostname.
