Outline
First, the relevant concept of FTP
Second, the FTP service implementation
Third, the implementation of virtual users with MySQL
First, the relevant concept of FTP
(1), FTP
FTP is the abbreviation for file Transfer Protocol (document Transfer Protocol), and Chinese is called "Interfax protocol". Used for two-way transmission of control files on the Internet. At the same time, it is also an application (application). There are different FTP applications based on different operating systems, and all of these applications follow the same protocol to transfer files. In the use of FTP, users often encounter two concepts: "Download" (Download) and "Upload" (Upload). A "Download" file is a copy of a file from a remote host to its own computer; the "upload" file is a copy of the file from your computer to a remote host. In the Internet language, users can upload (download) files to (from) a remote host through a client program.
(2), RPC (Remote Procedure Call)
Enables data communication between two processes on different hosts in a binary-based manner
(3), FTP two connections
Command Connection (21/TCP): A connection that transmits some control instructions, such as GET, put, etc.
Data connection: A connection dedicated to transferring data files
Active Mode: FTP server side actively use its own port 20th to connect to the port of the client
Passive mode: After the control instruction is issued, the FTP server notifies the client that it has opened a port to wait for the client to actively connect via a command connection, which is called a passive connection
(4), FTP data transmission mode
Text format: such as HTML, text, etc.
Binary format: such as MP3, JPEG, etc.
(5), type of data
Structured data: Data is stored in a database and can be logically expressed using a two-dimensional table structure
Semi-structured data: Data between fully structured data, such as relational databases, data in an object-oriented database, and completely unstructured data, such as sound, image files, and so on, HTML documents belong to semi-structured data
Unstructured data: Includes all forms of Office documents, text, images, XML, HTML, various types of reports, images and audio/video information, and more
(6), server-side programs
wu-ftpd
vsftpd
proftpd
pureftpd
FileZilla
ser-u:windows
Client programs
cli:ftp, Lftp
GUI:GFPD, FlashFXP, CuteFTP, FileZilla
(7), FTP user
Anonymous User: Anonymous
Virtual User:
System users:
(8), active mode work process
The ① client opens a random port (the port number is greater than 1024, where we call it X), and an FTP process connects to the server's 21st command port. At this point, the source port for the TCP connection is the random port x specified by the client, and the destination port (remote port) is Port 21st on the server.
The ② client starts listening on the port (x+1) and sends a port command (via the server's 21st command port) to the server, which tells the server that the client is listening on the port number and is ready to receive data from this port. This port is the data port we know of.
The ③ server opens the source port 20th and creates a connection to the client data port. At this point, the source port is 20 and the remote data (destination) port is (x+1).
The ④ client creates a connection to the server 20th port via the local data port, and then sends an answer to the server telling the server that it has created a connection.
(9), passive mode working process
The ① client opens a random port (the port number is greater than 1024, where we call it X), and an FTP process connects to the server's 21st command port. At this point, the source port for the TCP connection is the random port x specified by the client, and the destination port (remote port) is Port 21st on the server.
② When a client initiates a control command such as GET, the server sends a message to the client containing the random port Y (<1023<y<65535) that it intends to use to establish the data connection.
When the ③ client receives the message, it knows which port the server is ready to open to establish a transport channel connection. The client then creates a connection to the server Y port through the local x+1 port.
④ Server opens Y source port and creates and client x+1 port , at which point the source port is Y, remote data (destination) port for (x+1). It then sends an answer to the client, telling the client that it has created a connection.
This article is from the "Hello,linux" blog, make sure to keep this source http://soysauce93.blog.51cto.com/7589461/1725320
FTP Service for Linux file sharing