The process of connecting to the FTP server is not complex.

Source: Internet
Author: User

We know that to connect to the FTP server, we need to clarify the basic FTP protocol mode. So let's first review the basic content of the FTP protocol. It is defined as the File Transfer Protocol (FTP), which is used to send files from a host to another. The history of this protocol can be traced back to 1971 (at that time, net.cn was still in the experiment), but it is still very popular.

The FTP is described in RFC 959. Both HTTP and FTP are file transfer protocols, which have many common features, such as running on TCP. However, there are important differences between the two application-layer protocols. The most important difference is that FTP uses two parallel TCP connections, one is control connection and the other is data connection. The control connection is used to send control information between the client host and the server host, such as the user name and password, commands for changing the remote directory, commands for obtaining or returning files. Data Connection is used to send files. During the entire session, the FTP server must maintain the user's status. Specifically, the server must associate the control connection with a specific user and track the current directory as the user moves in the remote directory tree. Maintaining these state information for each active user session greatly limits the number of sessions that can be maintained simultaneously by FTP. Stateless HTTP does not have to maintain any user status information. The FTP service can work in active and passive modes:

Active mode is generally the default FTP server mode ):

The FTP client enables a randomly selected TCP port to connect to port 21 of the FTP server to establish a connection. After Three-Way Handshake is completed, the connection is successfully established, but this only controls the establishment of the connection. When the two ends need to transmit data, the client uses a port command to tell the server through the command channel, and the client can use another TCP port as the data channel. Then the server uses Port 20 to establish a data connection with the TCP port notified by the client just now. Note: The connection direction is from the server to the client, and there is a SYN flag in the TCP group. The client then returns an ACK flag validation group and completes another Three-Way Handshake process. At this time, the data connection can be successfully established. Start data transmission.

Passive Mode:

The FTP client enables a randomly selected TCP port to connect to port 21 of the FTP server to establish a connection and complete the establishment of the control connection. When the two ends need to transmit data, the client sends a PASV command to the server through the command channel, requiring the server to enter the passive transmission mode. Then, the server selects a TCP port and uses the control connection to notify the client, as in the preceding Active Mode Step 2nd. Then the client uses another TCP port to connect to the TCP port that the server just told to establish a data channel. In this case, the group contains SYN flag. The server returns an ACK group after confirmation. Complete the handshake process, establish a data channel, and start data transmission.

Currently, many FTP services can be implemented, such as IIS, Serv-U, wuFTP, and vsftp on Windows. Vsftp (Very Secure FTP) is a Secure, fast, and stable FTP server in Unix/Linux. It has been used by many large websites and vsftpd is also the default FTP service of RHEL, this article describes how to configure vsftp.

1. Install vsftp.

Rpm-ivh vsftpd-2.0.5-12.el5.rpm

After the installation is complete, the vsftpd configuration file is/etc/vsftpd. conf. Run the following command to start vsftpd and set it to automatic start.

Service vsftpd restartchkconfig vsftpd on

2. The first FTP site.

Vsftp can be used after it is installed and started. By default, anonymous users can use ftp commands.

1: Use the ftp command to connect to the FTP server.

2: currently, anonymous users are used to connect to the FTP server. Generally, all anonymous users are anonymous FTP servers are anonymous. The ftp users here are automatically created when vsftp is installed, this user is also an anonymous user of vsftp ).

After connecting to vsftp, the default directory is the user's home directory, while the ftp user's home directory is located in/var/ftp, all. If SELinux is enabled in RHEL, run the following command set sebool-P ftp_home_dir = 1 ).

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.