文件服务器 之 ProFTPD+MySQL 认证

作者: etony

来自: www.linuxsir.org

使用MySQL认证ProFTPD用户:

1. apt-get update //更新数据库

2. apt-get mysql-client mysql-server //安装MySQL

3. apt-get proftpd-mysql //安装支持MySQL的ProFTPD

4. mysql -uroot -p //用Root登录MySQL,

create database ftpdb //建ftpdb 数据库

grant select, update on ftpdb.* to proftpd@"%" identified by 'password' //新增一个用户,用于存取ftpdb 数据库,用户名 proftpd,密码 password

use ftpdb //对 ftpdb 库操作

#ftpgroup的表结构
CREATE TABLE `ftpgroup` (
`groupname` varchar(16) NOT NULL default '',
`gid` smallint(6) NOT NULL default '5500',
`members` varchar(16) NOT NULL default '',
KEY `groupname` (`groupname`)
) TYPE=MyISAM;

#插入一条记录
INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser');

#ftpuser的表结构
CREATE TABLE `ftpuser` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` varchar(32) NOT NULL default '',
`passwd` varchar(32) NOT NULL default '',
`uid` smallint(6) NOT NULL default '5500',
`gid` smallint(6) NOT NULL default '5500',
`homedir` varchar(255) NOT NULL default '',
`shell` varchar(16) NOT NULL default '/sbin/nologin',
`count` int(11) NOT NULL default '0',
`accessed` datetime NOT NULL default '0000-00-00 00:00:00',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;

#插入一条记录
INSERT INTO ftpuser (userid, passwd, uid, gid, homedir, shell) VALUES
('ftpuser', 'ftppasswd', 5501, 5500, '/tony','/sbin/nologin'); //目录/tony应该存在

5.修改/etc/proftpd.conf
加入以下内容:
########################################
DefaultRoot ~
SQLAuthTypes Plaintext Crypt
SQLAuthenticate users* groups*
SQLConnectInfo ftpdb@localhost proftpd password
SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLGroupInfo ftpgroup groupname gid members
SQLMinID 500
SQLHomedirOnDemand on
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
DeferWelcome on
RootLogin off
RequireValidShell off
########################################

6. /etc/init.d/proftpd stop
/etc/init.d/proftpd start //使用/etc/init.d/proftpd restart 似乎不能达到预期的效果

7.使用
用户名:ftpuser
密码:ftppasswd
测试

posted @ 2008-01-23 14:15  Jonson Li  阅读(275)  评论(0编辑  收藏  举报