Proftpd mysql认证配置文档

ver1.0, 2012/09/25

一、下载安装proftp mysql

下载 wget http://cloud.github.com/downloads/proftpd/proftpd.github.com/proftpd-1.3.4rc2.tar.gz

tar zxvf proftpd-1.3.4rc2.tar.gz

cd proftpd-1.3.4rc2

./configure--prefix=/usr/local/proftp \

--with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql \

--with-includes=/usr/include/mysql \

--with-libraries=/usr/lib/mysql \

make && make install

解释

--with-includes: 指定MySQL服务器includes所在的位置,mysql的include文件通常是.h结尾,

--with-libraries:指定MySQL服务器libraries所在的位置,mysql的库文件通常是*结尾

到此proftp已安装结束

mysql安装方式 yum安装编译安装。

二、创建proftp数据库

创建数据库proftp(utf-8)

导入附件中sql文件或,输入

CREATE TABLE IF NOT EXISTS `ftpgroup` (

`groupname` varchar(16) NOT NULL default '',

`gid` smallint(6) NOT NULL default '5500',

`members` varchar(16) NOT NULL default '',

KEY `groupname` (`groupname`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='ProFTP group table';

-- --------------------------------------------------------

--

-- Table structure for table `ftpquotalimits`

--

CREATE TABLE IF NOT EXISTS `ftpquotalimits` (

`name` varchar(30) default NULL,

`quota_type` enum('user','group','class','all') NOT NULL default 'user',

`per_session` enum('false','true') NOT NULL default 'false',

`limit_type` enum('soft','hard') NOT NULL default 'soft',

`bytes_in_avail` int(10) unsigned NOT NULL default '0',

`bytes_out_avail` int(10) unsigned NOT NULL default '0',

`bytes_xfer_avail` int(10) unsigned NOT NULL default '0',

`files_in_avail` int(10) unsigned NOT NULL default '0',

`files_out_avail` int(10) unsigned NOT NULL default '0',

`files_xfer_avail` int(10) unsigned NOT NULL default '0'

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--

-- Table structure for table `ftpquotatallies`

--

CREATE TABLE IF NOT EXISTS `ftpquotatallies` (

`name` varchar(30) NOT NULL default '',

`quota_type` enum('user','group','class','all') NOT NULL default 'user',

`bytes_in_used` int(10) unsigned NOT NULL default '0',

`bytes_out_used` int(10) unsigned NOT NULL default '0',

`bytes_xfer_used` int(10) unsigned NOT NULL default '0',

`files_in_used` int(10) unsigned NOT NULL default '0',

`files_out_used` int(10) unsigned NOT NULL default '0',

`files_xfer_used` int(10) unsigned NOT NULL default '0'

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--

-- Table structure for table `ftpuser`

--

CREATE TABLE IF NOT EXISTS `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 '2001',

`gid` smallint(6) NOT NULL default '2001',

`homedir` varchar(255) NOT NULL default '/home/web',

`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`),

UNIQUE KEY `userid` (`userid`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COMMENT='ProFTP user table' AUTO_INCREMENT=0 ;

三、配置proftpd.conf

备份原proftpd.conf文件,copy 附件中配置并修改以下几处内容

cp /usr/local/proftp/etc/proftpd.conf/usr/local/proftp/etc/proftpd.conf-bak

vi /usr/local/proftp/etc/proftpd.conf

替换以下内容(此部分可见文件夹中proftp.conf)

# This is a basic ProFTPD configuration file (rename it to

# 'proftpd.conf' for actual use.  It establishes a single server

# and a single anonymous login.  It assumes that you have a user/group

# "nobody" and "ftp" for normal operation and anon.

ServerName               "ProFTPD Default Installation"

ServerType                 standalone

DefaultServer                    on

DefaultAddress                 192.168.3.58

#SocketBindTight             on

# Port 21 is the standard FTP port.

Port                            21

# Don't use IPv6 support by default.

UseIPv6                      off

# Umask 022 is a good standard umask to prevent new dirs and files

# from being group and world writable.

Umask                        022 022

AllowRetrieveRestart            on

AllowStoreRestart               on

SyslogLevel                warn

# To prevent DoS attacks, set the maximum number of child processes

# to 30.  If you need to allow more than 30 concurrent connections

# at once, simply increase this value.  Note that this ONLY works

# in standalone mode, in inetd mode you should use an inetd server

# that allows you to limit maximum number of processes per service

# (such as xinetd).

MaxInstances                    30

# Set the user and group under which the server will run.

User                            ftpuser

Group                         ftpgroup

# To cause every FTP user to be "jailed" (chrooted) into their home

# directory, uncomment this line.

DefaultRoot ~

# Normally, we want files to be overwriteable.

AllowOverwrite          on

# Bar use of SITE CHMOD by default

#<Limit SITE_CHMOD>

#  DenyAll

#</Limit>

# A basic anonymous configuration, no upload directories.  If you do not

# want anonymous users, simply delete this entire <Anonymous> section.

#<Anonymous ~ftp>

#  User                      ftp

#  Group                          ftpg

#  # We want clients to be able to login with "anonymous" as well as "ftp"

#  UserAlias                     anonymous ftp

#  # Limit the maximum number of anonymous logins

#  MaxClients                  10

#  # We want 'welcome.msg' displayed at login, and '.message' displayed

#  # in each newly chdired directory.

#  DisplayLogin                welcome.msg

#  DisplayChdir                .message

#  # Limit WRITE everywhere in the anonymous chroot

#  <Limit WRITE>

#    DenyAll

#  </Limit>

#</Anonymous>

#LangPath        /usr/share/locale

#LangEngine on

#UseEncoding on #UTF-8 UTF-8

SQLAuthTypes Backend Plaintext

SQLAuthenticate users* groups*

# databasename@host database_user user_password

SQLConnectInfo  yourDBname@yourDBhost youeDBuser yourDBpass

#usertable ftpuser

SQLNamedQuery ftpuserinfo SELECT "userid,passwd,uid,gid,homedir,shell from ftpuser where userid = '%U' and count < 1"

SQLUserInfo custom:/ftpuserinfo

#SQLUserInfo ftpuser userid passwd uid gid homedir shell

#SQLLogFile "/usr/local/proftpd/sqllog"

SQLGroupInfo ftpgroup groupname gid members

#SQLHomedirOnDemand on

CreateHome  on

SQLDefaultGID 2001

SQLDefaultUID 2001

# Update count every time user logs in

SQLLog PASS updatecount

SQLNamedQuery updatecount UPDATE "count=count+1,accessed=now() WHERE userid='%u'" ftpuser

# Update modified everytime user uploads or deletes a file

SQLLog STOR,DELE modified

SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser

QuotaEngine on

QuotaDirectoryTally on

QuotaDisplayUnits Mb

QuotaShowQuotas on

#QuotaLog "/var/log/quota"

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"

SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies

SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies

QuotaLimitTable sql:/get-quota-limit

QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally

UseReverseDns off

IdentLookups off

修改以下2处

DefaultAddress修改为本ftp所在服务器ip地址

SQLConnectInfo  yourDBname@yourDBhost youeDBuser yourDBpass

修改数据名数据库用户及密码

四、添加proftp系统用户

1、添加ftp运行用户及组

groupadd ftpgroup -g 2001

adduser ftpuser -u 2001 -g 2001 -d /var/ftp -s /sbin/nologin

ps:uid 和gid 号可以自定义,设置后需要修改proftp.conf中SQLDefaultGID 2001

SQLDefaultUID 2001这两处,这里我新建的就是2001 所以proftp中我就没有修改

2、添加 ftp虚拟用户及组

groupadd ftpusers -g 2002

adduser proftp -u 2002 -g 2001 -d /var/ftp -s /sbin/nologin

ps:添加ftp用户,将其组加入到proftp运行组中,虚拟用户将继承2002 用户权限

五、初始化proftp配置

在数据库中插入

INSERT INTO `proftp`.`ftpgrps` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', '2001', 'ftpuser');

INSERT INTO `proftp`.`ftpgrps` (`groupname`, `gid`, `members`) VALUES ('ftpusers', '2002', 'proftp');

Proftpd mysql认证配置文档的更多相关文章

  1. MYSQL服务器my.cnf配置文档详解

    MYSQL服务器my.cnf配置文档详解 硬件:内存16G [client] port = 3306 socket = /data/3306/mysql.sock [mysql] no-auto-re ...

  2. Spring Hibernate4 整合配置文档

    1 applicationContext.xml配置文档 <?xml version="1.0" encoding="UTF-8"?><bea ...

  3. Kerberos主从配置文档

    Kerberos主从配置文档   1. Kerberos主从同步机制 在Master上通过以下命令同步数据: kdb5_util dump /var/kerberos/krb5kdc/slave_db ...

  4. python常用模块-配置文档模块(configparser)

    python常用模块-配置文档模块(configparser) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. ConfigParser模块用于生成和修改常见配置文档,当前模块的名称 ...

  5. azkaban编译安装配置文档

    azkaban编译安装配置文档 参考官方文档: http://azkaban.github.io/azkaban/docs/latest/ azkaban的配置文件说明:http://azkaban. ...

  6. nginx 安全配置文档

    1.配置文档中有多处明确写出了nginx的配置文件路径,该路径是测试环境中的路径,线上系统的nginx配置文件与文档中所写的路径可能不一样,在进行相关配置时,应以线上配置文件的实际路径为准. 线上系统 ...

  7. tomcat 安全配置文档

    1.配置文档中使用$CATALINA_HOME变量声明为tomcat的安装目录并明确写出了tomcat的配置文件路径,此路径为测试环境的路径,线上系统对应配置文件的路径可能不一样,在进行相关配置时,应 ...

  8. (转)tomcat 安全配置文档

    原文:https://www.cnblogs.com/heaven-xi/p/9961354.html 1.配置文档中使用$CATALINA_HOME变量声明为tomcat的安装目录并明确写出了tom ...

  9. (转)nginx 安全配置文档

    原文:https://www.cnblogs.com/heaven-xi/p/9961357.html#top 1.配置文档中有多处明确写出了nginx的配置文件路径,该路径是测试环境中的路径,线上系 ...

随机推荐

  1. Nginx 一些常用的URL 重写方法

    url重写应该不陌生,不管是SEO URL 伪静态的需要,还是在非常流行的wordpress里,重写无处不在. 1. 在 Apache 的写法 RewriteCond  %{HTTP_HOST}  n ...

  2. Pandoc PDF 中文

    最近终于又决定(^_^)使用reStructuredText写文档了,输出PDF时的中文问题必须要解决下. 安装环境 sudo apt install texlive texlive-latex-ex ...

  3. jdbcTemplaate queryForObject的两个易混淆的方法

    JdbcTemplate中有两个可能会混淆的queryForObject方法: 1.    Object queryForObject(String sql, Object[] args, Class ...

  4. 常用yum命令小结

    基于rpm的软件包管理器 yum,是Yellow dog Updater, Modified的简称,是一种软件包管理器.它能够从指定的服务器自动下载RPM包并安装,可以自动处理依赖性关系,并且一次安装 ...

  5. Android studio 混淆打包问题

    参考 : Android Studio代码混淆设置以及上传mapping文件 AndroidStudio 混淆打包 在app 目录下  proguard-rules.pro中加入 通用 混淆 #指定代 ...

  6. 华为基于策略划分VLAN的配置方法及示例

     学过思科交换机的朋友,可能对基于策略划分VLAN的配置方法印象非常深,感觉确实比较复杂,先要配置VMPS以及VMPS数据库,但在华为交换机中,这种现象得到了彻底改变,因为它有了一种特殊的端口类型—— ...

  7. Android 六大存储

    Android平台进行存储的方式: 一.使用SharedPreferences存储 二.文件存储数据 三.SQLite数据库存储 四.使用ContentProvider存储数据 五.网络存储数据 今天 ...

  8. lombok插件安装

    eclipse安装lombok插件 lombok注解介绍 记得最后,加入的配置文件中的jar包,最好写成相对路径,这样.eclipse移动位置后,不会报错.

  9. 初学shell,今天遇到由wget下载到本地的网页源代码的乱码问题,无聊的写了一个转码的脚本

    今天用wget想下载文件,结果下载了一堆本地的index.html文件,一查看全是乱码,然后百度了一下,网页的编码格式大概有三种: 1.utf-8 2.gb2312 3.gbk 要在网页源码中的< ...

  10. struts2的 defalut-action-ref 的使用

    这个配置的用法有值得注意的地方,所以才记录下来: 一般default-action-refer配置的action是在浏览器中输入的网址只输入到项目时或输入错误的action时 所进入的action,一 ...