Configure pure-ftpd in strongtuserver10.04

Source: Internet
Author: User
FTP supports two modes: Standard (PORT mode) and Passive (PASV mode ). The FTP client in Standard mode sends the PORT command to the FTP server. The client in Passive mode sends the PASV command to the FTPServer. The following describes the working principle of the two methods: Port mode FTP client first and FT

Preface:

How FTP works

FTP supports two modes: Standard (PORT mode) and Passive (PASV mode ). The FTP client in Standard mode sends the PORT command to the FTP server. The client in Passive mode sends the PASV command to the FTP Server.

The following describes how these two methods work:

In Port mode, the FTP client first establishes a connection with the tcp port 21 of the FTP server and sends commands through this channel. When the client needs to receive data, it sends the Port command through this channel. The PORT command contains the PORT used by the client to receive data. When transmitting data, the server connects to the specified port of the client through its TCP port 20 to send data. The FTP server must establish a new connection with the client to transmit data.

The Passive mode is similar to the Standard mode when a control channel is established, but the Port command is not sent after the connection is established, but the Pasv command. After receiving the Pasv command, the FTP Server opens a temporary port (also called the free port, with the port number greater than 1023 and less than 65535) and notifies the client to send data on this port, the client connects to this port of the FTP server, and the FTP server transfers data through this port. At this time, the FTP server no longer needs to establish a new connection with the client.

Many firewalls do not allow external connections when they are set. Therefore, many FTP servers located behind the firewall or on the intranet do not support the PASV mode, because the client cannot open the high-end PORT of the FTP server through the firewall, many Intranet clients cannot log on to the FTP server in PORT mode, because the slave server's TCP 20 cannot establish a new connection with the client of the internal network, it cannot work.

What is pure-ftpd in Ubuntu?

Ubuntu/Debian provides three different deb installation packages for Pure-FTPd: pure-ftpd, pure-ftpd-ldap, and pure-ftpd-mysql, ldap and mysql respectively indicate that Pure-FTPd is integrated with ldap and mysql, and the other three packages depend on pure-ftpd-common. If you do not need ldap or mysql, select pure-ftpd.

Configuration method

Unlike most other daemon, Pure-FTPd has a special configuration: it does not read any configuration files, and configuration options are implemented through command line parameters. For example, the '-H' parameter is designed to speed up the server by avoiding DNS queries. To enable this feature, we only need to add it to the command line: pure-ftpd-H. The alternative long parameter is also supported. Below is an equivalent command pure-ftpd -- dontresolve

For users who like configuration files, Pure-FTPd officially provides a solution: parse the configuration file and convert it into command line parameters using a wrapper tool. First edit the profile pure-ftpd.conf as needed, and then start the pure-config.pl/etc/pure-ftpd.conf through the following command. The pure-config.pl is a perl script that uses appropriate command line options based on the configuration file to call pure-ftpd.

In Ubuntu/Debian, developers adopt another wrapper method: instead of using a single configuration file, they create a directory of pure-ftpd under/etc, there are three directories, conf, auth, And db, and a file named pureftpd-alias-dir. Each configuration option is stored in the/etc/pure-ftpd/conf directory as a file, and the option value is the file content. For example, if you want to configure AnonymousOnly = yes (only anonymous users are allowed), create a file named AnonymousOnly in/etc/pure-ftpd/conf with only one line of content: yes.

In Ubuntu, we only focus on the last configuration method.

Environment:

1. Install pure-ftpd on an Ubuntu server 10.4 server and configure it to an FTP server.

2. log on to the Client using FileZilla Client.

Operation:

1. Install pure-ftpd

# Sudo apt-get install pure-ftpd

# Sudo netstat-nl

Check whether port 21 is enabled.

2. If you log on with a local account on the FileZilla Client, the following error occurs:

Solution: in/etc/pure-ftpd/conf, create the DontResolve file with the content "yes. Now the local account can use the FTP service.

3. Use a virtual account to manage users.

(1) manually create a home directory

# Sudo mkdir/var/ftp

# Sudo mkdir/var/ftp/js

(2) create a group and a user

# Sudo groupadd ftpadmins

# Sudo groupadd ftpusers

# Sudo useradd-g ftpadmins-d/dev/null-s/bin/false ftpadmin

# Sudo useradd-g ftpusers-d/dev/null-s/bin/false js

(3) change the corresponding Access Permissions

# Sudo chown-R ftpadmin/var/ftp/

# Sudo chmod-R 775/var/ftp/js

*: To prevent one user in the same group from deleting files of another user, make the following settings:

The content of the KeepAllFiles File Created in/etc/pure-ftpd/conf is yes # prohibit users from deleting files, except in the TrustedGID group.

Create a TrustedGID file in/etc/pure-ftpd/conf with the content 2002 # GID of ftpadmins In the Administrator group, which allows the Administrator to delete the file. Here, 2002 is the GID of ftpadmins.

(4) add virtual users

# Sudo pure-pw useradd admin-u ftpadmin-d/var/ftp

# Sudo pure-pw useradd js001-u js-d/var/ftp/js

Two files, pureftpd. passwd and pureftpd. pdb, will be added under/etc/pure-ftpd /.

# Sudo pure-pw list

# Sudo pure-pw show js001

Use the preceding two commands to view the corresponding user information. For more pure-pw usage, see man pure-pw.

(5) Make the virtual user take effect

# Sudo pure-pw mkdb

(6) If you use the pureDB authentication method, if you do not have the following steps, the virtual user will not be able to log on, and the error 530 will appear.

# Cd/etc/pure-ftpd/auth

# Sudo ln-s ../conf/PureDB 60 puredb

(7) restart the pure-ftpd Service

# Sudo/etc/init. d/pure-ftpd restart

Conclusion: pure-ftpd configuration is complete, and a simple FTP is set up.

However, the permission issue arises. Strict permission settings are not found in the pure-ftpd configuration. The related permissions include:

1. If your pure-ftpd is added with pure-uploadscript support during compilation, this command will make pure-ftpd

Send information about new uploads to/var/run/pure-ftpd.upload.pipe so that pure-uploadscript

Then you can read and call a script to handle the new upload.

Creating CallUploadScript content in/etc/pure-ftpd/conf to yes will generate pure-ftpd.upload.pipe under/var/run, pure-ftpd.upload.lock

I have not tried this method yet.

2, KeepAllFiles = yes # prohibit users from deleting files, except in the TrustedGID Group

TrustedGID = 1001 # GID of ftpadmins In the Administrator group, allowing the Administrator to delete files

ChrootEveryone = yes # restrict all users to their homedir

3. Map virtual users to different local users to control permissions. The disadvantage is that you need to create different local groups and users.

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.