FTP (File Transfer Protocol) is a network file transfer protocol created back in 1971.
This protocol works in "Client - Server" mode and it is an application protocol, along with such protocols as: HTTP; SMTP; DNS.
The server has a file system, which is a directory structure in which the files are located.
Principle of FTP
FTP uses a URL (uniform resource locator) to locate files, let us see how it does this:
For example, we have a URL link that allows us to download a document from our file server (example ftp://serverspace.io/host/doc/readme.txt). The URL consists of 3 parts.
- The first part is the ftp protocol identifier - [ftp://serverspace.io/host/doc/readme.txt] .
- The second part is the name of our server using DNS name or its ip address - [ftp://serverspace.io/host/doc/readme.txt].
- The third part is the path to the file in the file system of the server - [ftp://serverspace.io/host/doc/readme.txt].
Differently from the other application layer protocols FTP uses two connections:
- A control connection that runs on port 21.
- A data connection which works on port 20 in active mode.
In active FTP mode, the initiator for establishing a data connection is the server, in this case port 20 on the server will be used and on the client side ports from 1024 are used.
In passive FTP mode, the client initiates the data connection; in this mode, ports 1024 and above are used.
The client connecting to the server is able to interact with the file system, navigate through directories, copy data and perform other file system operations.
FTP requires the user to authenticate. A username and password must be entered, after which the user will have access to the directories that are assigned to the authentication user.
Another way of authenticating to the server is as an anonymous user. For its authorization you need to enter the user name "ftp ; anonymous" and a password (the password can be your login, or your mail). Anonymous users have many restrictions and access is allowed based on the anonymous user settings.
FTP these days
This protocol is used less often nowadays because of security related issues. The user ID and password are sent over the network in the clear, including the data. Many companies have migrated from FTP to other protocols based on SSH (SFTP, SCP). FTP is suitable for local networks, for example to transfer movies from a computer to a television within a network, where the computer will act as a server.
To create your own FTP server, you will need any personal computer with Windows, Linux, MacOS.
MacOS and Windows support acting as an FTP server, but you need to enable the FTP/SFTP option in your system settings.
On Linux, you will need to install and configure the "vsFTPd" package.