All Topics  
File Transfer Protocol

 

   Email Print
   Bookmark   Link






 

File Transfer Protocol



 
 
File Transfer Protocol (FTP) is a network protocol used to transfer data from one computer to another through a network such as the Internet
Internet

The Internet is a global network of interconnected computers, enabling users to share information along multiple channels. Typically, a computer that connects to the Internet can access information from a vast array of available server and other computers by moving information from them to the computer's local memory....
.

FTP is a file transfer protocol for exchanging and manipulating files over a TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
 computer network. An FTP client may connect to an FTP server to manipulate files on that server.

runs over TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
. It defaults to listen on port 21
List of TCP and UDP port numbers

In computer networking, the protocols of the Transport Layer of the Internet Protocol Suite, most notably the Transmission Control Protocol and the User Datagram Protocol , but also other protocols, use a numerical identifier for the data structures of the endpoints for host-to-host communications....
 for incoming connections from FTP clients.






Discussion
Ask a question about 'File Transfer Protocol'
Start a new discussion about 'File Transfer Protocol'
Answer questions from other users
Full Discussion Forum



Encyclopedia


File Transfer Protocol (FTP) is a network protocol used to transfer data from one computer to another through a network such as the Internet
Internet

The Internet is a global network of interconnected computers, enabling users to share information along multiple channels. Typically, a computer that connects to the Internet can access information from a vast array of available server and other computers by moving information from them to the computer's local memory....
.

FTP is a file transfer protocol for exchanging and manipulating files over a TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
 computer network. An FTP client may connect to an FTP server to manipulate files on that server.

Connection methods

FTP runs over TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
. It defaults to listen on port 21
List of TCP and UDP port numbers

In computer networking, the protocols of the Transport Layer of the Internet Protocol Suite, most notably the Transmission Control Protocol and the User Datagram Protocol , but also other protocols, use a numerical identifier for the data structures of the endpoints for host-to-host communications....
 for incoming connections from FTP clients. A connection to this port from the FTP Client forms the control stream on which commands are passed from the FTP client to the FTP server and on occasion from the FTP server to the FTP client. FTP uses out-of-band control
Out-of-band control

Out-of-band control is a characteristic of network protocols with which data control is regulated. Out-of-band control passes control data on a separate connection from main data....
, which means it uses a separate connection for control and data. Thus, for the actual file transfer to take place, a different connection is required which is called the data stream. Depending on the transfer mode, the process of setting up the data stream is different. Port 21 for control (or program), port 20 for data.

In active mode, the FTP client opens a dynamic port
Ephemeral port

An wiktionary:ephemeral port is a Transmission Control Protocol , User Datagram Protocol , or Stream Control Transmission Protocol TCP and UDP port number that is automatically allocated from a predefined range by the Internet protocol suite stack software, typically to provide the port for the Client end of a client-server communication....
, sends the FTP server the dynamic port number on which it is listening over the control stream and waits for a connection from the FTP server. When the FTP server initiates the data connection to the FTP client it binds the source port to port 20 on the FTP server.

In order to use active mode, the client sends a PORT command, with the IP and port as argument. The format for the IP and port is "h1,h2,h3,h4,p1,p2". Each field is a decimal representation of 8 bits of the host IP, followed by the chosen data port. For example, a client with an IP of 192.168.0.1, listening on port 49154 for the data connection will send the command "PORT 192,168,0,1,192,2". The port fields should be interpreted as p1×256 + p2 = port, or, in this example, 192×256 + 2 = 49154.

In passive mode, the FTP server opens a dynamic port, sends the FTP client the server's IP address to connect to and the port on which it is listening (a 16-bit value broken into a high and low byte, as explained above) over the control stream and waits for a connection from the FTP client. In this case, the FTP client binds the source port of the connection to a dynamic port.

To use passive mode, the client sends the PASV command to which the server would reply with something similar to "227 Entering Passive Mode (127,0,0,1,192,52)". The syntax of the IP address and port are the same as for the argument to the PORT command.

In extended passive mode, the FTP server operates exactly the same as passive mode, however it only transmits the port number (not broken into high and low bytes) and the client is to assume that it connects to the same IP address that was originally connected to. Extended passive mode was added by RFC 2428 in September 1998.

While data is being transferred via the data stream
Data stream

In telecommunications and computing, a data stream is a sequence of encoder coherent Signalling s used to Transmission or receive information that is in transmission ....
, the control stream sits idle. This can cause problems with large data transfers through firewalls
Firewall (networking)

A firewall is an integrated collection of security measures designed to prevent unauthorized electronic access to a networked computer system....
 which time out sessions after lengthy periods of idleness. While the file may well be successfully transferred, the control session can be disconnected by the firewall, causing an error to be generated.

The FTP protocol supports resuming of interrupted downloads using the REST command. The client passes the number of bytes it has already received as argument to the REST command and restarts the transfer. In some commandline clients for example, there is an often-ignored but valuable command, "reget" (meaning "get again") that will cause an interrupted "get" command to be continued, hopefully to completion, after a communications interruption.

Resuming uploads is not as easy. Although the FTP protocol supports the APPE command to append data to a file on the server, the client does not know the exact position at which a transfer got interrupted. It has to obtain the size of the file some other way, for example over a directory listing or using the SIZE command.

In ASCII mode (see below), resuming transfers can be troublesome if client and server use different end of line characters.

The objectives of FTP, as outlined by its RFC
Request for Comments

In computer network engineering, a request for comments is a memorandum published by the Internet Engineering Task Force describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems....
, are:
  1. To promote sharing of files (computer programs and/or data).
  2. To encourage indirect or implicit use of remote computer
    Remote computer

    A remote computer is a computer to which a user does not have physical access, but which he or she can access/manipulate via some kind of computer network....
    s.
  3. To shield a user from variations in file storage systems among different host
    Server (computing)

    A server is a computer program that provides services to other computer programs , in the same or other computer. The physical computer that runs a server program is also often referred to as server....
    s.
  4. To transfer data
    DATA

    Debt, AIDS, Trade in Africa is a multinational Non-governmental organization founded in January 2002 in London by U2's Bono along with Robert Sargent Shriver III and activists from the Jubilee 2000 Drop the Debt campaign....
     reliably, and efficiently.


Security problems

The original FTP specification is an inherently insecure method of transferring files because there is no method specified for transferring data in an encrypted fashion. This means that under most network configurations, user names, passwords, FTP commands and transferred files can be captured by anyone on the same network using a packet sniffer
Packet sniffer

A packet analyzer is computer software or computer hardware that can intercept and log traffic passing over a digital telecommunications network or part of a network....
. This is a problem common to many Internet protocol specifications written prior to the creation of SSL, such as HTTP, SMTP and Telnet
TELNET

Telnet is a network protocol used on the Internet or Local Area Network connections. It was developed in 1969 beginning with RFC 15 and standardized as Internet Engineering Task Force STD 8, one of the first Internet standards....
. The common solution to this problem is to use either SFTP
SSH file transfer protocol

In computing, the SSH File Transfer Protocol is a network protocol that provides file transfer and manipulation functionality over any reliable data stream....
 (SSH File Transfer Protocol), or FTPS
FTPS

FTPS is an extension to the commonly used File Transfer Protocol that adds support for the Transport Layer Security and the Secure Sockets Layer cryptographic protocols....
 (FTP over SSL), which adds SSL or TLS
Transport Layer Security

Transport Layer Security and its predecessor, Secure Sockets Layer , are cryptographic protocols that provide security and data integrity for communications over Internet Protocol Suite networks such as the Internet....
 encryption
Encryption

In cryptography, encryption is the process of transforming information using an algorithm to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key ....
 to FTP as specified in RFC 4217.

FTP return codes


FTP server return codes indicate their status by the digits within them. A brief explanation of various digits' meanings are given below:
  • 1xx: Positive Preliminary reply. The action requested is being initiated but there will be another reply before it begins.
  • 2xx: Positive Completion reply. The action requested has been completed. The client may now issue a new command.
  • 3xx: Positive Intermediate reply. The command was successful, but a further command is required before the server can act upon the request.
  • 4xx: Transient Negative Completion reply. The command was not successful, but the client is free to try the command again as the failure is only temporary.
  • 5xx: Permanent Negative Completion reply. The command was not successful and the client should not attempt to repeat it again.
  • x0x: The failure was due to a syntax
    Syntax

    In linguistics, syntax is the study of the principles and rules for constructing Sentence s in natural languages. In addition to referring to the discipline, the term syntax is also used to refer directly to the rules and principles that govern the sentence structure of any individual language, as in "the Irish syntax"....
     error.
  • x1x: This response is a reply to a request for information.
  • x2x: This response is a reply relating to connection information.
  • x3x: This response is a reply relating to accounting and authorization.
  • x4x: Unspecified as yet
  • x5x: These responses indicate the status of the Server file system vis-a-vis the requested transfer or other file system action.


Anonymous FTP

A host that provides an FTP service may additionally provide Anonymous
Anonymity

Anonymity is derived from the Greek word a??????a, meaning "without a name" or "namelessness". In colloquial use, the term typically refers to a person, and often means that the Identity , or personally identifiable information of that person is not known....
 FTP access as well. Under this arrangement, users do not strictly need an account on the host. Instead the user typically enters 'anonymous' or 'ftp' when prompted for username. Although users are commonly asked to send their email address as their password, little to no verification is actually performed on the supplied data.

As modern FTP clients typically hide the anonymous login process from the user, the ftp client will supply dummy data as the password (since the user's email address may not be known to the application). For example, the following ftp user agent
User agent

A user agent is the client application used with a particular network protocol; the phrase is most commonly used in reference to those which access the World Wide Web, but other systems such as Session Initiation Protocol use the term user agent to refer to the user's phone....
s specify the listed passwords for anonymous logins:

  • Mozilla
    Mozilla

    Mozilla was the official, public, original name of Mozilla Application Suite by the Mozilla Foundation, currently known as SeaMonkey internet suite....
     Firefox
    Mozilla Firefox

    Mozilla Firefox is a web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. Official versions are distributed under the terms of the proprietary EULA....
     (2.0) — mozilla@example.com
  • KDE
    KDE

    KDE is a free software project based around its flagship product, a desktop environment for Unix-like systems. The goal of the project is to provide basic desktop functions and applications for daily needs as well as tools and documentation for developers to write stand-alone applications for the system....
     Konqueror
    Konqueror

    Konqueror is a web browser, file manager and file viewer designed as a core part of the KDE. It is developed by volunteers and can run on most Unix-like operating systems....
     (3.5) — anonymous@
  • wget
    Wget

    GNU Wget is a simple computer program that retrieves content from web servers, and is part of the GNU Project. Its name is derived from World Wide Web and get, connotative of its primary function....
     (1.10.2) — -wget@
  • lftp (3.4.4) — lftp@


The Gopher protocol has been suggested as an alternative to anonymous FTP, as well as Trivial File Transfer Protocol
Trivial File Transfer Protocol

Trivial File Transport Protocol is a Computer file transfer network protocol, with the functionality of a very basic form of File Transfer Protocol ; it was first defined in 1980....
 and File Service Protocol
File Service Protocol

File Service Protocol is a User Datagram Protocol-based replacement for the File Transfer Protocol, designed for anonymous access with lower hardware and network requirements than FTP....
.

Data format

While transferring data over the network, several data representations can be used. The two most common transfer modes are:
  1. ASCII
    ASCII

    American Standard Code for Information Interchange , is a coding standard that can be used for interchanging information, if the information is expressed mainly by the written form of English words....
     mode
  2. Binary mode: In "Binary mode", the sending machine sends each file byte
    Byte

    A byte is a basic unit of measurement of Computer storage in computer science. In many computer architectures it is a Byte addressing memory address space....
     for byte and as such the recipient stores the bytestream as it receives it. (The FTP standard calls this "IMAGE" or "I" mode)


In "ASCII mode", any form of data that is not plain text will be corrupted. When a file is sent using an ASCII-type transfer, the individual letters, numbers, and characters are sent using their ASCII character codes. The receiving machine saves these in a text file in the appropriate format (for example, a Unix machine saves it in a Unix format, a Windows machine saves it in a Windows format). Hence if an ASCII transfer is used it can be assumed plain text
Plain text

In computing, plain text is a term used for an ordinary "unformatted" sequential file readable as textual material without much processing.The Character encoding has traditionally been either ASCII, one of its many derivatives such as ISO/IEC 646 etc., or sometimes EBCDIC....
 is sent, which is stored by the receiving computer in its own format. Translating between text formats might entail substituting the end of line and end of file characters used on the source platform with those on the destination platform, e.g. a Windows machine receiving a file from a Unix machine will replace the line feeds with carriage return
Carriage return

Originally, carriage return was the term for the control character in Baudot code on a Teleprinter for end of line return to beginning of line and did not include line feed....
-line feed pairs. It might also involve translating characters; for example, when transferring from an IBM mainframe
IBM mainframe

IBM mainframes, though perceived as synonymous with mainframe computers in general due to their marketshare, are now technically and specifically IBM's line of business computers that can all trace their design evolution to the IBM System/360....
 to a system using ASCII, EBCDIC
EBCDIC

Extended Binary Coded Decimal Interchange Code is an 8-bit character encoding used on IBM mainframe operating systems such as z/OS, OS/390, VM and VSE , as well as IBM midrange computer operating systems such as OS/400 and i5/OS ....
 characters used on the mainframe will be translated to their ASCII equivalents, and when transferring from the system using ASCII to the mainframe, ASCII characters will be translated to their EBCDIC equivalents.

By default, most FTP clients use ASCII mode. Some clients try to determine the required transfer-mode by inspecting the file's name or contents, or by determining whether the server is running an operating system with the same text file format.

The FTP specifications also list the following transfer modes:
  1. EBCDIC mode - this transfers bytes, except they are encoded in EBCDIC rather than ASCII. Thus, for example, the ASCII mode server
  2. Local mode - this is designed for use with systems that are word-oriented rather than byte-oriented. For example mode "L 36" can be used to transfer binary data between two 36-bit machines. In L mode, the words are packed into bytes rather than being padded. Given the predominance of byte-oriented hardware nowadays, this mode is rarely used. However, some FTP servers accept "L 8" as being equivalent to "I".


In practice, these additional transfer modes are rarely used. They are however still used by some legacy
Legacy system

A legacy system is an old computer system or application program that continues to be used, typically because it still functions for the users' needs, even though newer technology is available....
 mainframe
Mainframe computer

Mainframes are computers used mainly by large organizations for critical applications, typically bulk data processing such as census, industry and consumer statistics, Enterprise Resource Planning, and financial transaction processing....
 systems.

The text (ASCII/EBCDIC) modes can also be qualified with the type of carriage control used (e.g. TELNET NVT carriage control, ASA carriage control), although that is rarely used nowadays.

Note that the terminology "mode" is technically incorrect, although commonly used by FTP clients. "MODE" in RFC 959 refers to the format of the protocol data stream (STREAM, BLOCK or COMPRESSED), as opposed to the format of the underlying file. What is commonly called "mode" is actually the "TYPE", which specifies the format of the file rather than the data stream. FTP also supports specification of the file structure ("STRU"), which can be either FILE (stream-oriented files), RECORD (record-oriented files) or PAGE (special type designed for use with TENEX). PAGE STRU is not really useful for non-TENEX systems, and RFC1123 section 4.1.2.3 recommends that it not be implemented.

FTP and web browsers

Most recent web browser
Web browser

A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
s and file manager
File manager

A file manager or file browser is a computer program that provides a user interface to work with file systems. The most common operations used are create, open, edit, file viewer, computer printer, streaming media, rename, move, file copying, file deletion, attributes, properties, search/find, and permissions....
s can connect to FTP servers, although they may lack the support for protocol extensions such as FTPS
FTPS

FTPS is an extension to the commonly used File Transfer Protocol that adds support for the Transport Layer Security and the Secure Sockets Layer cryptographic protocols....
. This allows manipulation of remote files over FTP through an interface similar to that used for local files. This is done via an FTP URL
Uniform Resource Locator

In Information technology, a Uniform Resource Locator is a type of Uniform Resource Identifier that specifies where an identified resource is available and the mechanism for retrieving it....
, which takes the form ftp(s)://<ftpserveraddress>  (e.g., ftp://ftp.gimp.org/). A password can optionally be given in the URL, e.g.:   ftp(s)://<login>:<password>@<ftpserveraddress>:<port>. Most web-browsers require the use of passive mode FTP, which not all FTP servers are capable of handling. Some browsers allow only the downloading of files, but offer no way to upload files to the server.

FTP and NAT devices

The representation of the IP addresses and port numbers in the PORT command and PASV reply poses another challenge for Network address translation
Network address translation

In computer networking, network address translation is the process of modifying network address information in datagram packet headers while in transit across a traffic router for the purpose of remapping a given address space into another....
 (NAT) devices in handling FTP. The NAT device must alter these values, so that they contain the IP address of the NAT-ed client, and a port chosen by the NAT device for the data connection. The new address and port will probably differ in length in their decimal representation from the original address and port. This means that altering the values on the control connection by the NAT device must be done carefully, changing the TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
 Sequence and Acknowledgment fields for all subsequent packets. Such translation is not usually performed in most NAT devices, but special application layer gateways exist for this purpose.

See also Application-level gateway
Application-level gateway

In the context of computer networking, an application-level gateway consists of a security component that augments a Firewall or Network address translation employed in a computer network....


FTP over SSH (not SFTP)

FTP over SSH (not SFTP) refers to the practice of tunneling a normal FTP session over an SSH
Secure Shell

Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices. Used primarily on Linux and Unix based systems to access shell accounts, SSH was designed as a replacement for TELNET and other Computer security remote Shell s, which send information, notably passwords, in...
 connection.

Because FTP uses multiple TCP
Transmission Control Protocol

The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
 connections (unusual for a TCP/IP protocol that is still in use), it is particularly difficult to tunnel over SSH. With many SSH clients, attempting to set up a tunnel for the control channel (the initial client-to-server connection on port 21) will protect only that channel; when data is transferred, the FTP software at either end will set up new TCP connections (data channels) which will bypass the SSH connection, and thus have no confidentiality
Confidentiality

Confidentiality has been defined by the International Organization for Standardization as "ensuring that information is accessible only to those authorized to have access" and is one of the cornerstones of information security....
, integrity protection, etc.

Otherwise, it is necessary for the SSH client software to have specific knowledge of the FTP protocol, and monitor and rewrite FTP control channel messages and autonomously open new forwardings for FTP data channels. Version 3 of SSH Communications Security
SSH Communications Security

SSH Communications Security is a List of Finnish companies that is based in Helsinki and was founded by Tatu Yl?nen in 1995. It is known as the original developer of the Secure Shell protocol and it currently has about 80 employees....
's software suite, and the GPL licensed are two software packages that support this mode.

FTP over SSH is sometimes referred to as secure FTP; this should not be confused with other methods of securing FTP, such as with SSL/TLS (FTPS
FTPS

FTPS is an extension to the commonly used File Transfer Protocol that adds support for the Transport Layer Security and the Secure Sockets Layer cryptographic protocols....
). Other methods of transferring files using SSH that are not related to FTP include SFTP
SSH file transfer protocol

In computing, the SSH File Transfer Protocol is a network protocol that provides file transfer and manipulation functionality over any reliable data stream....
 and SCP
Secure copy

Secure Copy or SCP is a means of securely transferring computer files between a local and a remote Server or between two remote hosts, using the Secure Shell protocol....
; in each of these, the entire conversation (credentials and data) is always protected by the SSH protocol.

See also

  • FTAM
    FTAM

    FTAM, International Organization for Standardization standard 8571, is an Open Systems Interconnection Application layer protocol for File Transfer Access and Management....
  • FTPFS
    FTPFS

    FTPFS refers to file systems that support access to a File Transfer Protocol server through standard file system application programming interfaces ....
  • List of FTP server return codes
    List of FTP server return codes

    Below is a list of all return codes that may be issued by an File Transfer Protocol Server .See also List of FTP commands...
  • List of FTP commands
    List of FTP commands

    Below is a list of File Transfer Protocol commands that may be sent to an FTP Server , including all commands that are standardized in RFC 959 by the IETF....
  • List of file transfer protocols
    List of file transfer protocols

    A list of notable file transfer protocols:...
  • Managed File Transfer
    Managed File Transfer

    'Managed File Transfer' refers to software solutions that facilitate the secure transfer of data from one computer to another through a network ....
  • OBEX
    OBEX

    OBEX is a communications protocol that facilitates the exchange of binary objects between devices. It is maintained by the Infrared Data Association but has also been adopted by the Bluetooth Special Interest Group and the SyncML wing of the Open Mobile Alliance ....
  • Shared file access
  • TCP Wrapper
    TCP Wrapper

    TCP Wrapper is a host-based Networking Access control list system, used to Filter network access to Internet protocol suite servers on operating systems such as Linux or Berkeley Software Distribution....
  • Comparison of FTP client software
  • List of FTP server software
  • Comparison of FTP server software
    Comparison of FTP server software

    The table below compares basic characteristics of FTP Servers. This list is not exhaustive....


Further reading

  • RFC 959 – File Transfer Protocol (FTP). J. Postel, J. Reynolds. Oct-1985. This obsoleted the preceding RFC 765 and earlier FTP RFCs back to the original RFC 114.
  • RFC 1579 – Firewall-Friendly FTP.
  • RFC 2228 – FTP Security Extensions.
  • RFC 2428 – Extensions for IPv6, NAT, and Extended passive mode. Sep-1998.
  • RFC 2640 – Internationalization of the File Transfer Protocol.
  • RFC 3659 – Extensions to FTP. P. Hethmon. March-2007.


External links

  • — a review of the protocol notably from a security standpoint
  • (in PDF
    Portable Document Format

    Portable Document Format is a file format created by Adobe Systems in 1993 for document exchange. PDF is used for representing two-dimensional documents in a manner independent of the application software, hardware, and operating system....
     format)