Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Pureftpd to manage FTP permissions and disk quotas

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Pureftpd for FTP permissions and disk quota management", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Pureftpd for FTP permissions and disk quota management" bar!

Pureftpd is a fast, high-quality, fully functional ftp server, the most important thing is to support the setting of client default encoding, then how to use Pureftpd for FTP permissions and disk quota management, see below.

We choose Pure-ftpd as our tool.

Installation

Pure-ftpd is a mature ftp tool, and apt-get already has a packed package. We can easily install it directly through apt-get.

Apt-get install pure-ftpd-mysql

Configuration

Build a library in the database, which uses the previous hosting database. Create a table with the following statement:

CREATE TABLE users (

User varchar (16) NOT NULL default'

Status enum ('01m) NOT NULL default' 0'

Password varchar (64) NOT NULL default''

Uid varchar (11) NOT NULL default'- 1'

Gid varchar (11) NOT NULL default'- 1'

Dir varchar (128) NOT NULL default'

ULBandwidth smallint (5) NOT NULL default'0'

DLBandwidth smallint (5) NOT NULL default'0'

Comment tinytext NOT NULL

Ipaccess varchar (15) NOT NULL default'*

QuotaSize smallint (5) NOT NULL default'0'

QuotaFiles int (11) NOT NULL default 0

PRIMARY KEY (User)

UNIQUE KEY User (User)

) TYPE=MyISAM

This table will be used to store information about ftp users.

Then we need to modify the configuration file of pure-ftpd-mysql to tell pure-ftpd about the database.

It is assumed that you have configured mysql and have an available account.

Vim / etc/pure-ftpd/db/mysql.conf

Put in the following configuration

# account information is modified according to your own situation

MYSQLServer 127.0.0.1

MYSQLPort 3306

MYSQLSocket / var/run/mysqld/mysqld.sock

MYSQLUser easy

MYSQLPassword *

MYSQLDatabase hosting

# encryption method

MYSQLCrypt md5

# SQL statement to get data

# user authorization

MYSQLGetPW SELECT Password FROM users WHERE User= "\ L"

MYSQLGetUID SELECT Uid FROM users WHERE User= "\ L"

MYSQLGetGID SELECT Gid FROM users WHERE User= "\ L"

MYSQLGetDir SELECT Dir FROM users WHERE User= "\ L"

# limits on file size and number

MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User= "\ L"

MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User= "\ L"

# Uplink and downstream bandwidth restrictions

MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User= "\ L"

MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User= "\ L"

So pure-ftpd knows how to get data from mysql.

In order to get the GID and UID shown above, we need to create a virtual account for ftp. All users of FTP share the UID and GID of this virtual account, but do not need to create system users for each FTP user.

Groupadd-g 2001 ftpgroup

Useradd-u 2001-s / bin/false-d / bin/null-c "pureftpd user"-g ftpgroup ftpuser

We created ftpgroup groups with a GID of 2001 and ftpuser users with a UID of 2001. Now you can add data to the data table. QuotaSize is in M, and the directory points to our same path in mod-myvhost.

Then we lock the user in his own directory and do not allow him to access other people's directories through ftp:

Echo yes > / etc/pure-ftpd/conf/ChrootEveryone

Automatically create a directory when the specified directory does not exist

Echo yes > / etc/pure-ftpd/conf/CreateHomeDir

The setup is complete. Restart pure-ftpd.

/ etc/init.d/pure-ftpd-mysql restart

All the configurations have been completed. Let's try uploading files.

Login successful, upload file prompt does not have permission. This is due to the property setting of / data0/myapphost. Just change the whole directory to ftpuser.

Chown-R ftpuser:ftpgroup / data0/myapphost

After modifying the properties, you can upload the file. Try the quota limit:

Error: > [2010-1-27 22:47:12] could not write data socket. Socket error = # 10054.

[2010-1-27 22:47:12] 550-Quota exceeded: abc.zip won't be saved

5506 files used (120%)-authorized: 5 files

550 6974 Kbytes used (681%)-authorized: 1024 Kb

Error: > [2010-1-27 22:47:12] the requested operation was not performed (for example, the file or directory was not found and could not be accessed).

Error: > [2010-1-27 22:47:43] could not write data socket. Socket error = # 10054.

[2010-1-27 22:47:43] 550-Quota exceeded: abc.zip won't be saved

5504 files used (80%)-authorized: 5 files

3954 Kbytes used (386%)-authorized: 1024 Kb

Error: > [2010-1-27 22:47:43] the requested operation was not performed (for example, the file or directory was not found and could not be accessed).

It can be seen from the error message that the quota is already in effect. When the configuration is modified, ftp users who have logged in need to log back in before it will take effect.

Thank you for your reading, the above is the content of "how to use Pureftpd for FTP permissions and disk quota management". After the study of this article, I believe you have a deeper understanding of how to use Pureftpd for FTP permissions and disk quota management. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report