Centos Install Pure-ftpd using Yum

Source: Internet
Author: User
Tags anonymous chmod md5 ftp client create database vps ftp access iptables

The detailed steps for installing Pure-ftpd using Yum are as follows:

Step 1: configure the yum source

Backup (if other epel sources are configured)

Mv/etc/yum. repos. d/epel. repo/etc/yum. repos. d/epel. repo. backup

Download the new repo to/etc/yum. repos. d/

Http://mirrors.aliyun.com/repo/epel-6.repo wget-O/etc/yum. repos. d/epel. repo

Yum makecache


Step 2: install yum
Yum install pure-ftpd-y


Step 3: modify the configuration file

PureDB/etc/pure-ftpd/pureftpd. pdb
# Remove this line of comment and specify the path, which is the PureDB user database file.
VerboseLog yes
# Enable log/var/log/pureftpd. log
NoAnonymous yes
# Reject anonymous user logon
PassivePortRange 48000 50000
# Use passive mode to restrict ports.


Step 4: create an account and configure permissions
Groupadd ftpgroup
Useradd-g ftpgroup-s/sbin/nologin-d/dev/null ftpuser
Create a virtual account
Pure-pw useradd test-d/data/ftp/-u ftpuser-m
Configure directory permissions
Chown ftpuser. ftpgroup/data/ftp/-R


Step 5: configure firewall policies
Iptables-a input-p tcp -- dport 21-j ACCEPT
Iptables-a input-p tcp -- dport 48000: 50000-j ACCEPT


Step 6: Start pure-ftpd

Chkconfig pure-ftpd -- level 345 on
/Etc/init. d/pure-ftpd start

Install and configure pure-ftpd in CentOS 5.5 x86_64

Pure-ftpd introduction
You should have heard of pure-ftpd, a very useful ftp server. It has many functions and is safe. It can also be integrated with mysql to create and verify accounts through mysql, and implement features such as traffic limit and disk quota limit. This shows that you can implement Web management through a self-developed PHP program. You can view other functions on the official website.
Problems with installing pure-ftpd in Yum
The simplest way to install software in CentOS is to use yum. So I don't hesitate to install pure-ftpd. X86_64 is also found, I think there will be no problem. After installation, run/etc/init. d/pure-ftpd start and find [failed. Check the server log:
Tail-n 200/var/log/messages | grep ftp
If you see the following error:
Pure-ftpd :(? @?) [ERROR] Unable to switch capabilities: Operation not permitted
Congratulations! you have encountered the same problem as me (what is this ......). This will appear on openVZ-based vps. This type of vps limits one type of package libcap. so. This can only modify the settings of the master machine, which is unrealistic in VPS. The solution is also very simple. You can download the pure-ftpd source code package for compilation and installation. When compiling, add? The without-capabilities parameter is enough. The specific command is as follows:

Wget ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.29.tar.gz
Tar zxf pure-ftpd-1.0.29.tar.gz
Cd pure-ftpd-1.0.29
. /Configure -- without-capabilities -- with-virtualchroot -- with-mysql -- with-pam -- with-altlog -- with-mysql -- with-cookie -- with-throttling -- with-ratios -- -paranoidmsg -- with-quotas -- with-everything
Make install
Problems encountered during pure-ftpd compilation
First question
The following error occurs:

Configure: error: PAM headers not found.

Yum-y install pam-devel
Second question:
I installed CentOS 5.5 x86_64 and MySQL yum. When pure-ftpd is compiled, is it added? The following error occurs during compilation after the with-mysql parameter:
Checking for mysql_init in-lmysqlclient... No
Configure: error: libmysqlclient is needed for MySQL support
I am wondering, how can I find this missing? I can find it by using the find command. In/usr/lib64/mysql/, the four library files are honestly lying there. Is it necessary to install additional extension packages? Yum search libmysqlclient and below, even meters have this.
On GG's search, there were quite a few people who encountered this problem (there are articles related to rice in China). However, there are several solutions to this problem:
1. Do not add it during compilation? With-mysql parameter (of course not for us, we need mysql support)
2. Delete mysql, apache, php, etc. Install the compiled LAMP or LNMP suite. This is not a reality.
3. Modify the configure file in the pure-ftpd source code and add the compilation parameters to the mysql section. This is only applicable to earlier versions of pure-ftpd. The configure file of the new version has been changed.
4. Use ln-s to connect several libmysqlclients under/usr/lib64/mysql. so files point to other locations, such as/usr/local/mysql and/usr/include. I tried to create these shortcuts almost anywhere I can create them, or meters are useful. But some people can use it.
5. Disable SElinux and firewall. If you have tried SElinux, it will not work, and it feels insecure, so it will be turned on again after it is useless.
In short, I have tried some methods on the Internet.
I accidentally received a pure-ftpd rpm Package, which listed the library files on which he was running. libmysqlclient exists. I clicked in and checked it, federo has a dedicated mysql library package. I guess there should also be CentOS. As a result, yum search mysql found that, apart from mysql, some other packages were not installed on my local machine. I saw a package named mysql-devel, which should be similar, I tried to install pure-ftpd again, and it was so excited that it was successful. The problem was finally solved in two days.
Configure pure-ftpd
Next, after./config:

Make install
Cp pureftpd-mysql.conf/etc/
Cp config-file/pure-config.pl/usr/local/sbin/
Chmod 755/usr/local/sbin/pure-config.pl
Cp configuration-file/pure-ftpd.conf/etc/
Cp contrib/redhat. init/etc/rc. d/init. d/pureftpd
Chmod u + x/etc/rc. d/init. d/pureftpd
Chkconfig -- add pureftpd
Chkconfig -- level 2345 pureftpd on
Service pureftpd start
In this way, you can install pure-ftpd as a service to facilitate future use. After the startup is successful, the following information is displayed:
Start pure-config.pl: Running:/usr/local/sbin/pure-ftpd? Daemonize-A-c50-B-C8-D-fftp-H-I15-lmysql:/etc/pureftpd-mysql.conf-L10000: 8-m4-s-uize: 022-u100-j-k99-Z
After pureftpd is installed, we can configure it to support virtual users and store them in mysql.
First, we create user groups and user accounts used by pureftpd. All virtual accounts are mapped to the directory of this account. You can define a group number and a user number as long as the system is idle. The default value is 2001.

Groupadd-g 2001 ftpgroup
Useradd-u 2001-s/bin/false-d/bin/null-c "pureftpd user"-g ftpgroup ftpuser
Create a pureftpd data table and Grant mysql permissions:

Mysql-u root-p
Create database pureftpd;
Grant select, INSERT, UPDATE, DELETE, CREATE, drop on pureftpd. * TO 'pureftpd '@ 'localhost' identified by' corresponding password ';
Grant select, INSERT, UPDATE, DELETE, CREATE, drop on pureftpd. * TO 'pureftpd '@ 'localhost. localdomain 'identified by' corresponding password ';
Flush privileges;
USE pureftpd;
Create table ftpd (
User varchar (16) not null default '',
Status enum ('0', '1') 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)
) ENGINE = MyISAM default charset = gbk;
Let's take a look at the table structure.

Mysql> desc ftpd;
+ ------------- + --------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ------------- + --------------- + ------ + ----- + --------- + ------- +
| User | varchar (16) | NO | PRI |
| Status | enum ('0', '1') | NO | 0 |
| Password | varchar (64) | NO |
| Uid | varchar (11) | NO |-1 |
| Gid | varchar (11) | NO |-1 |
| Dir | varchar (128) | NO |
| ULBandwidth | smallint (5) | NO | 0 |
| DLBandwidth | smallint (5) | NO | 0 |
| Comment | tinytext | NO | NULL |
| Ipaccess | varchar (15) | NO | * |
| QuotaSize | smallint (5) | NO | 0 |
| QuotaFiles | int (11) | NO | 0 |
+ ------------- + --------------- + ------ + ----- + --------- + ------- +
12 rows in set (0.02 sec)
Data table description:
User: account name;
Status: 0 indicates that the account is disabled and cannot log on to the server;
Password: Password, encrypted using MD5;
Uid: the ftpuser account number created earlier. We have entered 2001;
Gid: Number of the ftpgroup group created earlier. We entered 2001;
Dir: the path of the virtual user's personal directory, which will be created under/home (the first login );
ULBandwidth: The maximum upload speed, KB/s, 0 is unlimited;
DLBandwidth: the download speed is limited, KB/s, and 0 is not limited;
Comment: remarks;
Ipaccess: * indicates that any IP address can access the ftp server. You can enter a specific IP address to allow only this IP address to connect to the server;
QuotaSize: disk space allocation. Unit: MB. 0 indicates no limit;
QuotaFiles: the number of files that can be saved by the user. 0 indicates no limit.
Edit/etc/pure-ftpd.conf to make sure ChrootEveryone, MySQLConfigFile, CreateHomeDir is enabled:

ChrootEveryone yes
CreateHomeDir yes
ChrootEveryone limits each virtual user to be in its directory;
CreateHomeDir creates a personal directory when an ftp user logs on.
Edit/etc/pureftpd-mysql.conf as follows:

MYSQLSocket/tmp/mysql. sock
# MYSQLServer localhost
# MYSQLPort 3306
MYSQLUser pureftpd
MYSQLPassword: enter the password used for mysql authorization.
MYSQLDatabase pureftpd
# MYSQLCrypt md5, cleartext, crypt () or password ()-md5 is very recommendable uppon cleartext
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User = "\ L" AND status = "1" AND (ipaccess = "*" OR ipaccess LIKE "\ R ")
Restart pureftpd:

Service pureftpd restart
Create an ftp Virtual User:

Mysql-u root-p
Use pureftpd;
Insert into 'ftpd' ('user', 'status', 'password', 'uid', 'gid', 'dir', 'ulbandwidth', 'dlbandwidth ', 'comment', 'ipaccess', 'quotasize ', 'quotafiles') VALUES ('account name', '1', MD5 ('password'), '123 ', '123', '/home/path', '123', '123', '',' * ', '50', '0 ');
Here, you can manually add SQL statements to create a web page, apply for an account, and set the account in the admin background to take effect... ... This php debut... ...
Now you can use your ftp client to connect to the ftp server.
Appendix: how to configure anonymous ftp access
Modify/etc/password as follows:

Ftp: x: 14: 50: FTP User:/home/anon_ftp_dir:/sbin/nologin
Add permissions to the anonymous access directory:

[Root @ server home] # chmod 755 anon_ftp_dir/
[Root @ server ~] # Ls-dl/home/anon_ftp_dir/
Drwxr-xr-x 3 root 4096 05-31 10: 07/home/anon_ftp_dir/
[Root @ server ~] # Ls-l/home/anon_ftp_dir/
Total 8
Drwxr-xr-x 2 root 4096 05-31 10: 07 anon
Log on to the FTP client and try again.

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.