Linux set up one of the FTP servers

  
        

First, what is FTP: Principle of File Transfer Protocol

The Internet File Transfer Protocol (FTP) standard is described in RFC959. The protocol defines a standard for transferring files between a remote computer system and a local computer system. In general, users who transfer files need to be authenticated before they can log in to the site before they can access files on the remote server. Most FTP servers often provide a GUEST public account to allow users without remote servers to access the FTP server.

An FTP session typically involves the interaction of five software elements.

The user interface provides a user interface and uses the client protocol interpreter's service client PI client protocol interpreter, whose entry remote server protocol machine sends commands and drives the client data transfer process server PI server protocol interpreter, Respond to the command issued by the client protocol machine and drive the server-side data transmission process client DTP client data transmission process, which is responsible for the completion and server data transmission process and the client local file system communication service DTP server data transmission process, which is responsible for the completion and customer data Transmission process and communication of server-side file system

In RFC 959, the term user is generally used to refer to a customer. RFC 959 defines the manner and specifications for customer PI and server PI interaction. The mechanism by which the user interface interacts with PI and DTP is not part of the protocol standard. PI and DTP are often implemented in the same program module.

In an FTP session, there are two separate network connections, one used by the PIs at both ends and the other by the DTPs at both ends. The connection between PIs is generally called a control connection, and the connection between DTPs is called a data connection.

Control and data connection using TCP services

Normally, the FTO server listens on port number 21 to wait for a control connection establishment request. The choice of the data connection port number depends on the command on the control connection. Usually the client sends a control message to specify the port number on which the client listens and waits for the server to send a data connection setup request.

The use of different independent connections for data transmission and control command transmission has the following advantages: two connections can choose different suitable quality of service, eg high control delays require less delay time, Data connections require greater data throughput; and the transparency and escaping of commands in the data stream can be avoided.

When the transfer is established, it is always initiated by the client first. However, both the client and the server may be data senders. In addition to transmitting the user request to download the file, the data transfer process is also established when the client requests the column server directory structure.

1. Command Selection

When a transfer is established, it is usually necessary to specify four attributes:

File Type This attribute specifies how to match the data of the file to There are four possible choices for the format suitable for transmission:

The ASCII file type is on the sender side, the file is converted from the local text file format to the NVT ASCII format, and there is a CR/LF pair at the end of each line. . At the receiving end, it is converted to a local text format.

This explains why the transfer of text files between Unix hosts is such that the amount of data transferred is greater than the actual size of the file. If the ASCII text encoding is not used for either the transmission end or the transmission end, the conversion between the local encoding and the NVT ASCII encoding should be implemented by the data transmission process.

The EBCDIC file type is similar to ASCII, except that it uses the EBCDIC character encoding

image (or binary) file type file to transfer content locally, at the far end exactly the same as the local Content storage.

Local file system Used in environments where the byte size is not 8 bits. No byte digits are specified by the sender.

In practical applications, only ASCII and image formats are used more.

Format Control This attribute is related to the final transfer of the text file to the printing device. There are several ways to encode the vertical format information into the file, including the way to indicate the start of a new page. There are the following options:

No need to print format control, this is the default value Telnet printing control, the control characters defined in the telnet protocol are included in the data stream. Fortran print control, this property is rarely used in practice.

Structure A file can have an internal structure that is preserved during transmission. There are three possibilities for the data transfer process to be responsible for matching the structure and local structure in the transport:

File structure This actually means that the file is treated as a contiguous stream of bytes without internal structure. .

Record Structure A file is a structure consisting of a series of records. This only applies to text files.

Page structure can also be called a block structure. Each page is transmitted with a page number to complete the transfer in a sequential manner. Page structures are rarely encountered in practice. The record structure is also not very common. The same effect can be obtained by using an ASCII file type for text files.

Transfer Mode This attribute can take three different values:

Stream Mode The file is transmitted as a byte stream.

Block mode Files are transferred as a block to a block, and each block has a header at the beginning.

Compression Mode A simple run length compression encoding is applied to compress successive identical bytes.

In practice, only streaming mode is generally used. Compression is generally achieved by using a variety of other utility programs.

When a transfer is established, the client typically specifies one or more of the attributes described earlier. If the server does not support an option, the server will respond with an error message to the client and does not have a negotiation mechanism.

FTP provides ample commands to allow users to establish connections and access remote file systems.

2. Command Format The

command is transmitted in the format of an NVT ASCII string. Each command begins with three or four uppercase NVT ASCII characters followed by an option parameter and a CR/LF pair to identify the end of the command.

The response consists of three NVT ASCII digits and an option message.

A long response may consist of multiple messages, the first three digits followed by a dash, and the last message without a dash. The middle message does not need to carry three numbers, but if you bring three numbers, you also need a dash.

Below is a list of all the commands. Commands with an asterisk are rarely used, so they are often not supported in a specific implementation.


String Meaning ABOR Abandon Transmission *ACCT Some systems associate accounts and users with file systems *ALLO allocates space for files to be transferred. Behind the parameters to determine the number of bytes *APPE Attach the file to the existing file CDUP Switch the current directory to the parent directory on the remote system CWD Change the working directory of the remote system DELE Delete the file of the remote system HELP Read server Help information, such as: list of supported commands


LIST Send a list of file names in the current working directory on a newly established data connection MKD Create directory MODE Specify the transfer mode, the portable parameters are: S , B or C. NLST sends a directory list NOOP empty operation in a current directory on a newly established data connection, preventing the connection from being disconnected. PASS provides a user login password, which must be followed immediately after the USER command. *PASV specifies the server data transfer process to listen to the client's data connection connection establishment request PORT specifies that the client listens for the port number of the connection waiting for the server to establish the PWD display the current work of the server side Register QUIT to log out and terminate the connection

*REIN Reinitialize, log out but not disconnect, must subsequently issue a new USER command *REST Restart the transfer of RETR from an identifier of the server from the remote The system retrieves a file RMD to delete a directory *RNFR specifies the old pathname of the file to be named, followed by an RNTO command *RNTO specifies the new pathname of the file to be named *SITE Site-specific server provided Service *SMNT structure loading, providing a remote system path name of a file system structure *STAT status information STOR Upload a file to the server, overwrite *STOU if the file already exists, upload a file to the server, do not overwrite the existing file STRU Specify the file structure, the parameter can be F, R or P. *SYST reports the operating system type of the remote system TYPE specifies the file type, the parameters can be A, E, I, L only TYPE A and TYPE I commonly used


The control connection command response has the following form:

Type Description 1yz Active initial response, in Send another command before waiting for another response 2yz to actively answer, the last command successfully ends 3yz active intermediate response, must send another command 4yz temporary passive response, the requested action can not be completed at the time, but can retry 5yz permanent passive response, The requested action cannot be completed and should not be retried

"y"Number Encoding Further Information

Digit Meaning 0 Syntax Error 1 Information 2 Connection Status 3 Authentication and Accounting 4 Reserved 5 File s File System Status

Here are some typical messages:

Number Meaning 125 Data Connection Open, Transfer Start 200 Command OK 331 User Name OK Need to Enter Password 425 Cannot Open Data Connection 452 Error Write File 500 syntax error - unrecognizable life

For details, see RFC

The official authority of wu-Ftpd is http://www.wu-ftpd.org.

Copyright © Windows knowledge All Rights Reserved