File Transfer Protocol or
FTP is a network protocol used to transfer files between hosts or computers. FTP protocol is created as a client-server model where the server serves the files and different single or multiple clients can connect to the server and download or upload files. FTP first created as a command-line protocol where the client connects to the FTP server via command line and files on the server are listed in a command-line interface by using different FTP commands.
FTP history goes back to 1971 where the Unix operating system creation era. In the 1970s the TCP/UDP protocol doesn’t exist and NCP protocol was popular. FTP protocol is developed by the Abhay Bhushan with the RFC 114. As you expect the FTP protocol is one the first protocol created by the IETF or RFC community. With the emerge of the TCP/UDP protocol suite new version of the FTP standard has been published with the RFC 765 in 1980 and updated to RFC 959 in 1985. The current version and extensions of the FTP has been published with the RFC 1579, RFC 2228, RFC 2428.
How FTP Works?
FTP works as client and server model where the server is listening for TCP port 21 and the client connects to this TCP port 21. During the connection, if the configured FTP server can ask for login credentials like username and password. When the authentication phase is passed the client will see the root path of the FTP server. The client can list, navigate, download or upload files and folders to and from the FTP server with FTP commands but most of the users prefer GUI based FTP clients for easier operation without typing a command and only using the mouse.
What is FTP Port?
FTP uses TCP ports 20 and 21 by default. But for different versions and FTP related ports uses following port numbers.
- BFTP uses port 152 which is not so popular
- FTP over TSL/SSL encryption uses port numbers 989 and 990
- NI FTP uses port 47
- RSFTP uses port 26
- SFTP is another secure FTP implementation uses port 115
- TFTP is downgraded version of FTP uses UDP port 69
FTP Data Types
As a data transfer protocol FTP provides different data types to be transferred. At the time the FTP protocol is created text files are popular with ASCII and EBCDIC encoding and related data types are created to transfer this type of data. FTP data types are listed below where the image or binary mode is the most popular.
ASCII or TYPE A data type is a simple text where data is encoded with the ASCII format and transferred one by one as character.
IMAGE or TYPE A or Binary is the most popular data tye where data is transferred as byte by byte and the encoding is not important which can be an image or executable or a zip file etc.
EBCDIC or TYPE E data type is created for EBCDIC formatted text files.
LOCAL or TYPE L n data type is created to transfer data as byte but different sizes like 8 bit, 16, bit etc. It is like an extension to the IMAGE or TYPE A.
FTP Data Transfer Modes
FTP provides following data transfer modes.
Stream mode (MODE S) is designed to transfer data as a continuoes data stream and processes with the TCP protocol. Currently this mode is not used.
Block mode (MODE B) is desifned for transferring record-oriented files. This is the most popular and defacto data transfer mode.
Compressed Mode (MODE C) is designed to transfer data in a compressed manner to save bandwidth.
FTP is an old and clear text protocol where the data transferred between the FTP client and server and there is no security mechanism to protect the transmission between client and server by default. Especially in the 1980s and 1990s, the security threats were fewer but in the 2000s there are a lot of security threats increased a lot. Some security mechanisms like authentication and encryption are added to the FTP protocol.
Anonymous FTP is a popular method in order to provide FTP access to all users without different usernames with any provided password. The username for the anonymous FTP is anonymous which is used as a user ID. Generally, the password will be automatically provided by the FTP server or accepts any provided password and the FTP client software use this returned password for the anonymous user. Below you can find an anonymous FTP user login steps and communication. We can see that the user-provided email address is accepted as a password even it is not valid.
220 The date and time is Fri May 26 18:03:03 2005 Name (ftp.poftut:erpl08): anonymous 331 Guest login ok, send your email address as password. Password: enter your email address 230 Guest login ok, access restrictions apply. ftp>