FTP (File Transfer Protocol) is an application layer protocol that is used to transfer files between a client and a server. The user interacts with FTP via an FTP agent.
The following steps are involved in transferring a file using FTP:
The user provides the name of the host that it wants to connect with.
The FTP client establishes a TCP connection on port 20 with the server.
The user authenticates itself to the remote server.
After being authenticated, the user can transfer from or to the server.
The server initiates another TCP connection with the client to send a file to the user or to receive a file from the user. This connection is called a data connection.
FTP closes the data connection after the file is transferred. In the case of multiple files, the server initiates a new TCP connection for every file.
Some of the common commands used in FTP are:
USER username
Used to send the username to the server.
USER password
Used to send the password to the server.
RETR filename
Used to get a file from the server’s current directory.