One of the FTP servers set up in Linux

Source: Internet
Author: User
Set up one of the FTP servers in Linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. I. What is FTP: Principles of File Transfer Protocol

The File Transfer Protocol (FTP) standard is described in RFC959. This Protocol defines a standard for transferring files between a remote computer system and a local computer system. Generally, users who transmit files must first pass authentication before they can log on to the website and then access the files on the remote server. Most FTP servers usually provide a public account of GUEST to allow users without remote servers to access the FTP server.

An FTP session usually includes five software elements for interaction.

A user interface provides a service that uses a client protocol interpreter.
Customer PI customer protocol interpreter, its remote server protocol machine sends commands and drives the customer data transmission process
The server PI server protocol interpreter responds to commands issued by the client protocol machine and drives the data transmission process on the server.
The customer's DTP is responsible for completing the data transmission process with the server and communicating with the client's local file system.
Service DTP server data transmission process, which is responsible for communicating with the customer data transmission process and the Server File System

In RFC 959, the term "user" is generally used to represent a customer. RFC 959 defines the methods and specifications for interaction between customer PI and server PI. The interaction mechanism between user interfaces and PI and DTP is not part of the protocol standard. PI and DTP are usually implemented in the same program module.

In an FTP session, two independent network connections exist. One is used by the PI at both ends, and the other is used by the DTP at both ends. A connection between PI is generally called a control connection. A connection between DTP is called a data connection)

Use TCP Service Control and Data Connection

Generally, the FTO server listens to port 21 to wait for the control connection establishment request. The data connection port number depends on the control connection command. Generally, a customer sends a control message to specify the port number of the customer's listener and waits for the server to send a data connection to establish a request.

For data transmission and control command transmission, using different independent connections has the following advantages: two connections can choose different appropriate service quality, such as: For control connections, high requires a lower latency, for data connections, a larger data throughput is required. In addition, commands in the data stream can be transparent and escaped.

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

1. select commands

When a transmission is created, you usually need to specify four attributes:

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

ASCII file type
On the sender side, the file is converted from the local text file format to the nvt ascii format, and each row ends with a CR/LF pair to identify. At the receiving end, it is converted to a local text format.

This explains why text files are transferred between Unix hosts and the data volume is larger than the actual size of files. If no ASCII text encoding is used at either the transmission end or the transmission end, the conversion between local encoding and nvt ascii encoding should be implemented during the data transmission process.

EBCDIC file type
Similar to ASCII, only EBCDIC character encoding is used.

Image (or binary) file type
Files are transmitted locally and stored in the same local content at the remote end.

Local File System
It is used in an environment where the byte size is not 8 bits. The number of bytes is specified by the sender.

In practice, only ASCII and image formats are used.

Format Control
This attribute is related to the final transfer of a text file to a print device. There are multiple ways to encode the vertical format information to a file, including the method to indicate the start of a new page. You can choose from the following methods:

No printing format control required. This is the default value.
Telnet print control. The control characters defined in the telnet protocol are included in the data stream ..
Fortran printing control,
This attribute is rarely used in practice.

Structure
The file can have an internal structure, which is retained during transmission. The data transmission process is responsible for matching the structure and local structure in the transmission. There are three possibilities:

File structure
This actually means that the file is regarded as a continuous byte stream without an internal structure.

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

Page Structure
It can also be called a block structure. Each page is transmitted along with a page number to complete transmission in order.

Page Structure is rarely encountered in practice. The record structure is not very common. You can use the ASCII file type for text files to achieve the same effect.

Transmission Mode
This attribute can have three different values:

Stream Mode
The file is transmitted in byte streams.

Block Mode
The file is transmitted in a block connection mode. Each block starts with a header.

Compression Mode
A simple route length compression encoding is applied to compress consecutive identical bytes.

In reality, only the stream mode is used. Compression is generally obtained by using a variety of other tool programs.

When a transmission is established, the client generally specifies one or more attributes described above. If the server does not support a certain option, the server uses an error message to respond to the client, and does not have a negotiation mechanism.

FTP provides sufficient commands to allow users to establish connections with remote access to the remote file system.

2. Command Format

The command is transmitted as an nvt ascii string. Each command starts 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

A response consists of three nvt ascii numbers and one option message.

A long response may contain multiple messages. The three digits of the first message are followed by a break number, and the last message is not. There is no need to carry three numbers in the middle of the message, but if there are three numbers, a break is required.

The following is a list of all commands. Commands with asterisks are rarely used, so they are often not supported in specific implementations.

String Meaning
ABOR discard Transfer
* Some ACCT systems associate accounts and users with file systems
* ALLO allocates space for the files to be transferred. The following parameters are used to determine the number of bytes.
* Append an existing file to APPE.
CDUP switches the current directory to the parent directory in a remote system.
CWD changes the working directory of the remote system
DELE deletes files from a remote system.
HELP reads HELP information from the server, such as the list of supported commands.
LIST send the file name LIST in the current working directory on a newly established data connection
Create a directory for MKD
MODE specifies the transmission MODE. Portable parameters include S, B, and C.
NLST sends a "full" directory list under the current directory on a newly established data connection.
NOOP is null to prevent connection disconnection
PASS provides a USER logon password, which must be followed immediately after the USER command
* PASV specifies that the server's data transmission process listener waits for the client's data connection to establish a request
PORT specifies the PORT number of the client listening waiting for the connection established by the server.
PWD displays the current working directory name on the server.
QUIT log out and terminate the connection
* REIN reinitialization. log out but the connection is not closed. A new USER command must be issued later.
* REST transmission starts again from a server ID.
RETR retrieves a file from the remote system
RMD deletes a directory
* RNFR specifies the old path name of the file to be named, followed by an RNTO command
* RNTO specifies the new path name of the file to be named
* Services provided by SITE-specific servers
* SMNT structure loading: Provides the remote system path name of a file system structure
* STAT status information
STOR uploads a file to the server. If the file already exists, it overwrites
* STOU uploads a file to the server and does not overwrite the existing file
STRU specifies 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, and L. Only type a and type I are commonly used.

The control connection command responds in the following form:

Type Description
1yz initiates a preliminary response and waits for another response before sending another command
2yz takes the initiative to final the response, and the last command is successfully completed
3yz initiates an intermediate response and must send another command
4yz temporarily responds passively. The requested action cannot be completed at the time, but you can try again.
5yz responds passively permanently, and the requested action cannot be completed. Retry is not recommended.

"Y" numeric encoding further information

Digit Meaning
0 syntax errors
1. Information
2 connection status
3 certification and Accounting
4 Reserved
5 File s File system status

Below are some typical messages:

Number Meaning
125 data connection is enabled and transmission starts
200 command OK
331 enter the password when the user name is OK
425 data connection cannot be enabled
452 file writing error
500 syntax error-unrecognized life

For more information, see RFC.

The official website address of wu-Ftpd is :.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.