Building efficient FTP server with Linux sharing 1th/2 page _ftp server

Source: Internet
Author: User
Tags anonymous ftp client file transfer protocol ftp protocol

In many network applications, FTP (File Transfer Protocol) has a very important position. A very important resource in the Internet is software resources, and most of the various software resources are placed in the FTP server. Like most Internet services, FTP is also a client/server system. The user connects to the FTP server program on the host through a client program that supports the FTP protocol. The user sends a command to the server program through a client program that executes the command issued by the user and returns the results of the execution to the client.

The FTP service can be divided into two categories depending on the service object: The System FTP server allows only legitimate users on the system; an anonymous FTP server (Anonymous) allows anyone to log on to the FTP server to obtain files.

FTP data transmission mode for FTP data connection, divided into active transmission mode, passive transmission mode and single port transmission mode three kinds.

1. Active transfer Mode

When the FTP control connection is established, the customer presents the directory list, transmits the file, the client sends out the port command to negotiate with the server, the FTP server uses a standard port 20 as the server side data connection port (Ftp-data), establishes the data connection with the customer. Port 20 is only used to connect the source address to the server side, and Port 20 does not have a listener process to listen for client requests.

In the active transfer mode, the FTP data connection and the control connection direction, by the server to the client to initiate a connection for data transfer. The client's connection port is determined by the server-side and the client through negotiation.

2. Passive transfer Mode

When the FTP control connection is established, the customer presents the directory list, transmits the file, the client sends the PASV command to make the server in the passive transmission mode, the FTP server waits for the customer to contact with. The FTP server listens for client requests on other data transfer ports other than Port 20.

In passive transmission mode, FTP data connections and control connections are in the same direction, and the client initiates a connection to the server for data transfer. The client's connection port is the port to use when initiating the data connection request. When an FTP client accesses an FTP server outside the firewall, it needs to use the passive transfer mode.

3. Single port mode

In addition to the above two modes, there is also a single port mode. The data connection request for this mode is initiated by the FTP server. When this transport mode is used, the client's control connection port is consistent with the data connection port. This pattern is not commonly used because it cannot continuously enter data and transmit commands in a short period of time.

Linux has a lot of available FTP servers, which are more popular with wu-ftp (Washington University FTP) and vsftp. Red Hat 8.0 has its own wu-ftp and vsftp two software. Wu-ftp is a well-known FTP server software, it is powerful and can run well in many Unix operating systems. But as an up-and-comer vsftp More and more popular, in the Red Hat 9.0 release version only with Vsftp.

In Vsftp, the meaning of VS is "Very Secure". As you can see from the name, the creator of the software has been very focused on its security. In addition to the inherent safety, VSFTP also has high-speed, stable performance characteristics. In terms of stability, vsftp can support more than 4,000 concurrent users at the same time on a stand-alone (non-clustered) connection. According to ftp.redhat.com data, VSFTP can support up to 15,000 concurrent users.

quickly build an FTP server

The basic function of FTP server is to upload the download, the following is a few steps to build a simple FTP server can achieve the download function.

1. Installing an FTP server

If you do not choose to install the FTP server when you install the system, you can install it through the Add/Remove Applications tool in red Hat 9.0. The specific method is, select "Main Menu" → "System settings" → "Add/Remove Application", select the FTP server in the pop-up interface, click "Update".

If you cannot confirm that the software is installed, you can use the following command to view:

     
     
      
      #rpm-qa|grep vsftpd
vsftpd-1.1.3-8
     
     

2. Start the FTP server

Start vsftp directly by applying the default example of Red Hat 9.0.

#/sbin/service VSFTPD Start

Start vsftpd for vsftpd: [OK]

3. Create a file named Test.txt in the/var/ftp/pub directory with the content "This is a test file".

4. Test

Log on to the local server using an FTP client, and then log on as Anonymous (anonymous):

     
     
      
      # FTP 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
VSFTPD 1.1.3
Name (127.0.0.1:root): Anonymous 331 Please specify the password
.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
     
     

This allows you to successfully log on to the FTP server. You can display a list of server directories as follows:

     
     
      
      ftp> ls
entering passive Mode (127,0,0,1,63,15) is here
comes the directory listing.
Drwxr-xr-x 2 0 0 4096 Dec 01:35 pub
Directory send OK.
     
     

Switch to the pub directory, and display the contents of the directory, you can find the file you just created Test.txt:

     
     
      
      Ftp> CD Pub
Directory successfully changed.
ftp> ls
entering passive Mode (127,0,0,1,232,34) is here
comes the directory listing.
-rw-r--r--1 0 0 Dec 01:35 test.txt
Directory send OK.
     
     

Download Test.txt file:

     
     
      
      ftp> mget test.txt
mget test.txt entering passive
mode (127,0,0,1,186,210) Opening
D ATA Connection for Test.txt (bytes).
The File send OK.
Bytes received in 0.0108 secs (1.9 kbytes/sec)
     
     

To view the contents of the native directory, you can see that Test.txt has been successfully downloaded to this computer.

     
     
      
      Ftp>!ls
a  eio_binders initrd mnt proc the tftpboot
bin etc     Lib    ylg.txt  root   tmp
boot home    lost+found myshare sbin   usr
dev id_dsas.pub misc    opt   Test.txt var
     
     

Attempting to upload a file named Ylg.txt, you can see that the request was rejected.

     
     
      
      Ftp> put Ylg.txt
local:ylg.txt remote:ylg.txt entering passive
Mode (127,0,0,1,243,10)
550 Permission denied.
     
     

Sign Out:

     
     
      
      ftp> bye
221 Goodbye.
     
     

As you can see from the tests, you can already download files, but you cannot upload files (and you cannot create directories and files on the server). In fact, this is an anonymous FTP server that provides download services specifically.

From the above steps can be seen, do not need to do what configuration can be completed a simple FTP server Setup. This is because Red Hat is already configured with the default FTP server. However, in practical applications, this simple server does not meet the requirements in most cases.

Current 1/2 page 12 Next read the full text
Related Article

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.