FTPD(8)

πŸ“¦
version 0.17.36+0.3 Β· 4 versions
, in debian bookworm, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… FTPD(8) πŸ’…

okay so real talk: this is the manual page for ftpd, and it lives in the System Manager's Manual (that's section 8, bestie β€” admin territory πŸ‘‘). It's long, so buckle up.


πŸŽ€ NAME πŸŽ€

ftpd β€” Internet File Transfer Protocol server. that's it, that's the whole vibe.


✨ SYNOPSIS ✨

ftpd [-AdDhlMnPSU] [-T maxtimeout] [-t timeout] [-u mask] [-z debug]
     [-z debug=file] [-z certsok] [-z certrequired] [-z secure] [-z ssl]
     [-z verify=flags] [-z cacert=cafile] [-z cert=certfile]
     [-z key=keyfile] [-z cipher=list] [-z legacy]

🌸 DESCRIPTION 🌸

So ftpd is the Internet File Transfer Protocol server process, fr fr. It uses the TCP protocol and it listens at the port that's specified in the ftp service specification β€” go peek at services(5) for that, iykyk.

Here are the options you can hand it:

  • -4 β€” IPv4 addressing only, no IPv6 energy today. The default is to offer service for both families, IPv6 and IPv4.
  • -6 β€” Only provide IPv6 addressing capability. IPv6 or nothing, periodt.
  • -A β€” Permit only anonymous ftp connections, or accounts listed in /etc/ftpchroot. Every other connection attempt gets refused, sorry not sorry. Heads up though: this option is no longer effective if PAM is enabled 😭. Go read the README file for instructions on how to do this with PAM instead.
  • -d β€” Debugging info gets written to the syslog using LOG_FTP.
  • -D β€” With this set, ftpd will detach and become a daemon, accepting connections on the FTP port and forking child processes to handle them. Lower overhead than starting ftpd from inetd(8), so it's genuinely useful on busy servers to reduce load πŸ”₯.
  • -h β€” The server will use data ports in the high port range for passive connections. That range is defined by the IPPORT_HIFIRSTAUTO and IPPORT_HILASTAUTO defines in <netinet/in.h>. In OpenBSD they're set to 49152 and 65535 respectively.
  • -l β€” Every successful and failed ftp(1) session gets logged using syslog with a facility of LOG_FTP. And if you specify this option twice, it also logs the retrieve (get), store (put), append, delete, make directory, remove directory and rename operations, plus their filename arguments. Double the logging, double the tea β˜•.
  • -M β€” Enables multihomed mode. Instead of just using ~ftp for anonymous transfers, a directory matching the fully qualified name of the IP number the client connected to β€” and located inside ~ftp β€” is used instead. Fancy.
  • -n β€” Use numeric IP addresses in logs instead of doing a hostname lookup. Speedrun mode πŸƒβ™€οΈ.
  • -P β€” Permit illegal port numbers or addresses for PORT command initiated connects. By default ftpd(8) violates the RFC and thus constrains the PORT command to non-reserved ports, and requires it use the same source address as the connection came from. This is what prevents the "FTP bounce attack" against services on both the local machine and other local machines. So like… turning this on is a choice, bestie 🚨.
  • -S β€” With this option set, ftpd logs all anonymous transfers to the file /var/log/ftpd when this file exists.
  • -U β€” Each concurrent ftp(1) session is logged to the file /var/run/utmp, making them visible to commands such as who(1). BUT β€” this option at present is unsupported and will always silently fail πŸ’€. It's giving decorative.
  • -T β€” A client may also request a different timeout period; the maximum period allowed may be set to timeout seconds with the -T option. The default limit is 2 hours.
  • -t β€” The inactivity timeout period is set to timeout seconds (the default is 15 minutes).
  • -u β€” Change the default umask from 027 to mask.
  • -z SSL-parameter β€” This option is only valid if ftpd has been built with SSL (Secure Socket Layer) support. Here's the whole menu:
    • secure β€” Don't fall back to unencrypted mode (that's without SSL) if the client isn't explicitly asking for SSL mode. In this server mode, ftpd only accepts connections from SSL enhanced FTP clients with an option similar to -z secure in active use. No vibes, only encryption πŸ”’.
    • ssl β€” Negotiate SSL at first, then fall back to legacy FTP protocol.
    • nossl, !ssl β€” switch off SSL negotiation.
    • debug β€” Enable SSL related debugging. Useless in non-daemon mode.
    • debug=file β€” Direct the debugging output to file.
    • certsok β€” Look username up in /etc/ssl.users. The format of this file is lines of this form: user1,user2:/C=US/... where user1 and user2 are usernames. If the client certificate is valid, authenticate with any password. Use a command openssl x509 -noout -subject to extract the needed fields, all of which are needed.
    • certrequired β€” Client certificate is mandatory, and the user must be matched to the corresponding subject identifier listed in /etc/ssl.users.
    • verify=int β€” Set the SSL verify flags (use combinations of SSL_VERIFY_* from openssl/ssl.h).
    • cacert=ca_file β€” Use the CA certificates stored in ca_file to verify the identity of the peer client. The subject names found herein are given to the client for whatever use they may present. A clever client software is able to choose its identity hinted by this list.
    • cert=cert_file β€” Use the certificate(s) in cert_file instead of the default location /etc/ftpd-ssl/ftpd.pem. This is a PEM formatted file. The first certificate identifies the server, and the rest of the chain is used for verification purposes while talking to the peer client.
    • key=key_file β€” Use the key stored in key_file, should the certificate file not contain the required private key.
    • cipher=ciph_list β€” Set the preferred ciphers to ciph_list. See openssl/ssl.h for more information).
    • legacy β€” This is a compatibility option, which activates a work around during verification, which the legacy code depended on. It should not be used now that chains and CA lists are available, but is introduced to ease the transition to the better implementation. It's giving deprecated, bestie 🫠.

The file /etc/nologin can be used to disable ftp access. If that file exists, ftpd displays it and exits. If the file /etc/ftpwelcome exists, ftpd prints it before issuing the "ready" message. If the file /etc/motd exists, ftpd prints it after a successful login. And if the file .message exists in a directory, ftpd prints it when that directory is entered. Little welcome mats everywhere 🏑✨

The ftp server currently supports the following ftp requests. The case of the requests is ignored.

  • 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
  • EPRT β€” specify data connection port, either IPv4 or IPv6
  • EPSV β€” ask for a server port for fetching data
  • 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:

  • UMASK β€” change umask, e.g. ``SITE UMASK 002''
  • IDLE β€” set idle-timer, e.g. ``SITE IDLE 60''
  • CHMOD β€” change mode of a file, e.g. ``SITE CHMOD 755 filename''
  • HELP β€” give help information.

The remaining ftp requests specified in Internet RFC 959 are recognized, but not implemented. And heads up β€” 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 five rules.

  1. The login name has to actually exist in the password database, /etc/passwd, and it can not have a null password, bestie. If it's a real one, the client has to hand over a password before it's allowed to do anything file-related. And if the user has an S/Key key? The response from a successful USER command comes back with an S/Key challenge πŸ’…. The client can then reply with a PASS command carrying either a regular password or an S/Key one-time password, and the server will figure out all by itself which kind it got and try to authenticate accordingly. Want the tea on S/Key auth? Go read skey(1). S/Key is a Trademark of Bellcore, fyi.
  2. The login name must not show up in the file /etc/ftpusers. No gatecrashers allowed, periodt.
  3. The user needs a standard shell β€” one that getusershell(3) returns. If it doesn't come back from there, it's giving "not today" 🚫.
  4. If the user name appears in /etc/ftpchroot, the session's root gets changed to that user's login directory by chroot(2), exactly like it works for an "anonymous" or "ftp" account (peep the next item πŸ‘€). BUT β€” and this is the important part β€” the user still has to supply a password. This feature is literally designed as a compromise between a fully anonymous account and a fully privileged one. The account should also be set up the same way you'd set up an anonymous account. Iconic middle-ground energy ✨.
  5. If the user name is "anonymous" or "ftp", there must be an anonymous ftp account present in the password file (user "ftp"). In that case the user gets to log in by specifying any password at all β€” by convention you'd use an email address for the user as the password πŸ’Œ.

In that last case, ftpd pulls out the special measures to lock down what the client can touch. The server performs a chroot(2) to the home directory of the "ftp" user. And so that system security does not get breached, it is recommended β€” like, strongly, bestie β€” that the "ftp" subtree be constructed with care, following these rules:

  • ~ftp β€” Make the home directory owned by "root" and unwritable by anyone (mode 555). Hands off 🫢.
  • ~ftp/bin β€” Make this directory owned by "root" and unwritable by anyone (mode 511). This directory is required, no skips, and should contain at least a statically linked copy of ls(1.). Any programs in here should be mode 111 (executable only).
  • ~ftp/etc β€” Make this directory owned by "root" and unwritable by anyone (mode 511). The files passwd(5) and group(5) must be present, otherwise ls can't produce owner names instead of just numbers 😭. The password field in passwd is not used, and should not contain real passwords β€” do not put your actual secrets in there, I am begging. The file motd, if present, gets printed after a successful login. These files should be mode 444.
  • ~ftp/lib β€” Make this directory owned by "root" and unwritable by anyone (mode 511). The libraries ld-linux.so.2 and libc.so.6 (or whatever your ls command is linked to) must be present. And in order to read passwd(5) and group(5), the library libnss_files.so.2 is also needed. Heads up: if you're on a 2.2.* or later Linux kernel, ld-linux.so.2 must be executable as well as readable (555). All other files should be mode 444.
  • ~ftp/pub β€” Make this directory mode 555 and owned by "root". This is traditionally where publically accessible files are stored for download. The main character directory, honestly πŸ‘‘.

πŸ“ FILES πŸ“

  • /etc/ftpusers β€” List of unwelcome/restricted users. The banned list 🚫.
  • /etc/ftpchroot β€” List of normal users who should be chroot'd.
  • /etc/ftpwelcome β€” Welcome notice.
  • /etc/motd β€” Welcome notice after login.
  • /etc/nologin β€” Displayed and access refused.
  • /var/run/utmp β€” List of users on the system.
  • /var/log/ftpd β€” Log file for anonymous transfers.
  • /etc/ftpd-ssl/ftpd.pem β€” Default certificate and key for SSL authentication.
  • /etc/ssl.users β€” List of trusted users and their subject identifiers.

🌱 ENVIRONMENT 🌱

Ftpd accesses a single environment variable:

  • SSL_CIPHER β€” containing a list of acceptable cipher combinations. That's it, that's the one πŸ”.

πŸ‘€ SEE ALSO πŸ‘€

ftp(1), skey(1), who(1), getusershell(3), ftpusers(5), syslogd(8)


πŸ’€ BUGS πŸ’€

The server must run as the super-user to create sockets with privileged port numbers. It maintains an effective user ID of the logged in user, and only reverts back to the super-user when it's binding addresses to sockets. The possible security holes have been extensively scrutinized, but are possibly incomplete. So like… scrutinized, yes, but possibly incomplete β€” read that twice, bestie πŸ˜­πŸ”’.


πŸ¦‹ HISTORY πŸ¦‹

The ftpd command appeared in 4.2BSD. Ancient. Legendary. Grandmother of file transfer daemons, fr fr.


And that's a wrap on the FTPD(8) page, babes ✨ β€” this one's from Linux NetKit (0.17), dated September 14, 1999 (yes, a literal 90s icon πŸ’…), and it's filed under FTPD(8). Go forth and chroot responsibly πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from