系统环境:centos6.0 64位 Mysql5.5
1、安装Mysql——省略
2、安装pam-mysql(文章末尾有下载)
tar zxvf pam_mysql-0.6.2.tar.gz
cd pam_mysql-0.6.2
./configure --with-mysql=/usr/local/mysql
make;make install |
3、创建数据库和授权
/usr/local/mysql/bin/mysql -uroot -p123456
create database vsftpd;
use vsftpd
create table users(name char(20), passwd char(20));
insert into users values(''lihuipeng'',''123456'');
grant select, insert, update on vsftpd to ''vsftpd''@localhost identified by ''vsftpd'';
flush privileges; |
4、安装Vsftpd
5、配置虚拟用户
vi /etc/vsftpd/vsftpd.conf
listen=YES
connect_from_port_20=YES
ftpd_banner=Welcome to virtual FTP service.
anonymous_enable=NO
local_enable=YES
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
chroot_local_user=YES
guest_enable=YES
guest_username=root #虚拟用户映射的实体用户
pasv_min_port=30000
pasv_max_port=30999
pam_service_name=vsftpd.vu #Mysql认证机制
user_config_dir=/etc/vsftpd/virtual #虚拟用户权限配置
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
hide_file=.*
|
PS:建议不要用root,另外建立一个实体用户做映射
Mysql认证机制
vi /etc/pam.d/vsftpd.vu
auth required /lib/security/pam_mysql.so user=vsftpd passwd=vsftpd host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=passwd crypt=0
account required /lib/security/pam_mysql.so user=vsftpd passwd=vsftpd host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=passwd crypt=0
|
虚拟用户权限配置
mkdir /etc/vsftpd/virtual
vi lihuipeng #每个虚拟用户(Mysql创建的用户)对应一个权限文件
anon_world_readable_only=NO
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
local_root=/
|
虚拟用户权限常用有以下三种(上面我用的是管理员权限):
[anvycn]仅仅允许下载
anon_world_readable_only=NO
local_root=/usr/local/apache/htdocs/anvy_test/
[dym529]允许建立,修改,但是不允许删除
anon_world_readable_only=NO
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
local_root=/usr/local/apache/htdocs/dym_test/
[admin]全部权限
anon_world_readable_only=NO
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
local_root=/usr/local/apache/htdocs/
|
|