Tag: pure-ftpd

pure-ftpd+mysql认证+pma

Posted by – 2009-03-12

#########################
#pure-ftpd+mysql认证+pma#
#Author: 楚霏 #
#Date: 2009-3-11 #
#Env: Centos 5.2 x86_64 #
#########################
#教程写的是很简单,但配置过程倍受折磨。请转载时加上本页链接,谢谢
#http://www.chengyongxu.com/blog/pure-ftpdmysql认证pma/
一. 准备工作:
环境:Centos 5.2 x86_64
所需软件:
mysql-5.1.32-linux-x86_64-icc-glibc23.tar.gz
pure-ftpd-1.0.21.tar.gz
phpMyAdmin-3.1.3-all-languages.tar.gz
####################################
下载相关软件
cd /usr/local/src
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
下面这两个软件下载后上传至服务器
#http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.32-linux-x86_64-icc-glibc23.tar.gz/from/pick#mirrors
mysql-5.1.32-linux-x86_64-icc-glibc23.tar.gz

#http://www.phpmyadmin.net/home_page/index.php
phpMyAdmin-3.1.3-all-languages.tar.gz
####################################
二、安装过程
(1)MySQL服务的安装
#如果系统中已经有web+php+mysql环境,此步请跳过
cd /usr/local/src
tar zxvf mysql-5.1.32-linux-x86_64-icc-glibc23.tar.gz
mv mysql-5.1.32-linux-x86_64-icc-glibc23 /usr/local/
ln -s /usr/local/mysql-5.1.32-linux-x86_64-icc-glibc23 /usr/local/mysql
useradd mysql -M
chown -R mysql:root /usr/local/mysql/
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
vi /etc/my.cnf
----------------- my.cnf说明 -------------------
务必指定datadir的位置, 一般是/var/lib/mysql
------------------------------------------------
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
chown -R mysql:mysql /var/lib/mysql
cd /usr/local/mysql/bin
for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done
(2)pure-ftpd安装
#如果不进行下边这步刚编译时会出现configure: error: Your MySQL client libraries aren't properly installed错误
echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf && ldconfig
cd /usr/local/src && tar xvf pure-ftpd-1.0.21.tar.gz && cd pure-ftpd-1.0.21
./configure --prefix=/usr/local/pureftpd --with-mysql --with-mysql-lib-dir=/usr/local/mysql --with-paranoidmsg --with-uploadscript --with-cookie --with-virtualchroot --with-virtualhosts --with-virtualroot --with-diraliases --with-quotas --with-sysquotas --with-ratios --with-ftpwho --with-throttling --with-puredb --with-shadow --with-pam --with-peruserlimits --with-language=simplified-chinese --with-altlog --with-iplogging --with-largefile
make && make install
make install-strip
(3)增加用户和组
#不增加用户会出现530 login authentication failed错误
groupadd ftpgroup
useradd ftpuser -g ftpgroup -d /www/wwwroot/ -s /sbin/nologin
chown -R ftpuser:ftpgroup /www/wwwroot
(3)配置
mkdir /usr/local/pureftpd/etc
cp configuration-file/pure-ftpd.conf !$/
cp pureftpd-mysql.conf /usr/local/pureftpd/etc/
vi /usr/local/pureftpd/etc/pure-ftpd.conf
#修改以下选项
##########################################
65c65
DisplayDotFiles yes ---> DisplayDotFiles no
77c77
NoAnonymous no ---> NoAnonymous yes
116c116
# MySQLConfigFile /etc/pureftpd-mysql.conf ---> MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
246c246
AllowUserFXP no ---> AllowUserFXP yes
324c324
#NoChmod yes ---> NoChmod yes
336c336
#CreateHomeDir yes ---> CreateHomeDir yes
429c429
# IPV4Only yes ---> IPV4Only yes
##########################################
vi /usr/local/pureftpd/etc/pureftpd-mysql.conf
#修改以下选项
##########################################
27c27
MYSQLUser root---> MYSQLUser pureftpd
32c32
MYSQLPassword rootpw ---> MYSQLPassword (yourpasswd)
45c45
MYSQLCrypt cleartext ---> MYSQLCrypt md5
##########################################
(4)启动
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
cp contrib/redhat.init /etc/init.d/pureftpd
chmod 755 /etc/init.d/pureftpd
chkconfig --add pureftpd
chkconfig --level 3 pureftpd on
#修改/etc/init.d/pureftpd,根据实际情况改一下相关路径
vi /etc/init.d/pureftpd
#----------------------------引用文字-开始----------------------------
#!/bin/bash
#
# Startup script for the pure-ftpd FTP Server $Revision: 1.3 $
#
# chkconfig: 2345 85 15
# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
# processname: pure-ftpd
# pidfile: /var/run/pure-ftpd.pid
# config: /etc/pure-ftpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# Path to the pure-ftp binaries.
prog=pure-config.pl
fullpath=/usr/local/pureftpd/sbin/$prog
pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho

start() {
echo -n tiny_mce_markerquot;Starting $prog: "
$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf --daemonize
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/$prog
echo
}
stop() {
echo -n tiny_mce_markerquot;Stopping $prog: "
kill $(cat /var/run/pure-ftpd.pid)
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ] ; then
stop
# avoid race
sleep 3
start
fi
;;
status)
status $prog
RETVAL=$?
if [ -f $pureftpwho ] && [ $RETVAL -eq 0 ] ; then
$pureftpwho
fi
;;
*)
echo tiny_mce_markerquot;Usage: $prog {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
#----------------------------引用文字-结束----------------------------
(5)mysql里建库、增加用户、授权
mysql -p
mysql> create database pureftpd;
mysql> grant all on pureftpd.* to pureftpd@localhost identified by 'yourpasswd' with grant option;
mysql> use pureftpd;
mysql> CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `user` varchar(16) NOT NULL, `password` varchar(64) NOT NULL, `uid` varchar(11) NOT NULL, `gid` varchar(11) NOT NULL, `dir` varchar(128) NOT NULL, `quotasize` varchar(5) NOT NULL, `quotafiles` varchar(11) NOT NULL, `ulbandwidth` varchar(5) NOT NULL, `dlbandwidth` varchar(5) NOT NULL, `ulratio` varchar(6) NOT NULL, `dlratio` varchar(6) NOT NULL, `comment` tinytext NOT NULL, `ipaccess` varchar(15) NOT NULL, `status` enum('0','1') default NULL, `create_date` datetime NOT NULL, `modify_date` datetime NOT NULL, PRIMARY KEY (`id`,`user`) ) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1;
(6)用pma管理pureftpd
#进入你的网站目录
cd /www/wwwroot/
tar xvf /usr/local/src/phpMyAdmin-3.?.?-all-languages.tar.gz
#把pma目录改的尽可能的难以猜解,我这里就先用简单的了
mv phpMyAdmin* pma
cd pma && mv config.sample.inc.php config.inc.php
#更改登录认证信息,一般为你mysql的root用户密码
vi config.inc.php
#登录pma
http://yoursite/pma
#新增用户时记得password的数据类型要和你pureftpd-mysql.conf中MYSQLCrypt的设置一致,我设的是md5
(7)启动服务,验证登录
service pureftpd start
ftp 127.0.0.1
#----------------------------引用文字-开始----------------------------
Connected to 127.0.0.1.
220---------- 欢迎来到 Pure-FTPd ----------
220-您是第 1 个使用者,最多可达 50 个连接
220-现在本地时间是 17:44。服务器端口: 21。
220-这是私人系统 - 不开放匿名登录
220 在 15 分钟内没有活动,您被会断线。
500 安全扩充项未实施
500 安全扩充项未实施
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): test1
331 使用者 test1 OK. 需要密码.
Password:
230-使用者 test1 有以下组的权限:: 502
230-这个服务器支持FXP传输
230 OK. 目前限制的目录是 /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,93,176)
150 接受数据连接
drwxr-xr-x 3 501 501 4096 Jan 16 23:10 wwwroot
226-Options: -l
226 总共 1 符合
ftp>
#----------------------------引用文字-结束----------------------------

#完成

linux+pure-ftpd(匿名登录)

Posted by – 2009-01-21

#################################
#linux+pure-ftpd#####################
#Author:楚霏########################
#Date: 2009-1-19#####################
#Env: Centos 5.2 x86_64################
#################################

一、准备工作
环境:Centos 5.2 x86_64
所需软件:
pure-ftpd-1.0.21.tar.gz
####################################
下载相关软件

cd /usr/local/src
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
####################################

二、安装过程

cd /usr/local/src && tar xvf pure-ftpd-1.0.21.tar.gz && cd pure-ftpd-1.0.21

编译时加了很多选项,为了日后使用方便

./configure --prefix=/usr/local/pureftpd --with-mysql=/usr/local/mysql --with-virtualchroot --with-virtualhosts --with-virtualroot --with-diraliases --with-uploadscript --with-cookie --with-quotas --with-sysquotas --with-ratios --with-ftpwho --with-throttling --with-largefile --with-peruserlimits --with-paranoidmsg --with-welcomemsg --with-language=simplified-chinese --with-altlog --with-iplogging --without-usernames

#生成配置文件
cp configuration-file/pure-config.pl /usr/local/sbin/
chmod u+x /usr/local/sbin/pure-config.pl
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
cp contrib/redhat.init /etc/rc.d/init.d/pureftpd
vi /etc/rc.d/init.d/pureftpd
--修改如下----------------------------------------------
找到语句: "pureftpwho=/usr/local/sbin/pure-ftpwho",
将其改为: "pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho"
找到语句: ”$fullpath /usr/local/etc/pure-ftpd.conf –daemonize”
将其改为: ”$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf –daemonize”
--保存退出----------------------------------------------

chmod u+x /etc/rc.d/init.d/pureftpd
chkconfig --add pureftpd
chkconfig --level 23 pureftpd on
/usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf &

三、启动

services pureftpd start

四、匿名登录

经上面的步骤,pureftpd已启动。用 命令或ftp工具 连接,只能系统用户连接(用“/etc/passwd”文本文件中的用户认证)。 这是因为默认的配置文件中是允许匿名用户和系统用户(根帐号 root 除外)都可以访问的。但这时匿名用户还无法访问,会出现“421 无法建立安全匿名 FTP”错误。还需要几个步骤才能实现匿名登录。
pureftpd 的官方文件说:
------------------------ SETTING UP AN ANONYMOUS FTP ------------------------
If a 'ftp' user exists and its home directory is reachable, Pure-FTPd will
accept anonymous login, as 'ftp' or 'anonymous'. Files have to be located in
the home FTP directory. There's no need for 'bin', 'lib', 'etc' and 'dev'
directories, nor any external program. Don't chown the public files to
'ftp', just writable directories ('incoming') .
就是说需要存在一个名称必须为“ftp”的系统用户,并且它的主目录可用。就可以实现匿名用户登录了。

#检查ftp用户是否存在

less /etc/passwd

#如不存在

#为匿名用户添加系统帐号和组。
#增加一个“ftp”组:
groupadd ftp
#添加“ftp”系统用户:
useradd ftp -g 14 -d /var/ftp -s /sbin/nologin
其中的 “/var/ftp”就是匿名用户的主目录,你可以指定为其它目录,如“/home/ftp”等。14是“ftp”组的组id 。如果发现帐号是存在的,那么请检查帐号的主目录是否存在,如果不存在,也会提示上述错误。
#建立匿名用户的主目录。
mkdir /var/ftp/
touch /var/ftp/testfile

#开启匿名访问

vi /usr/local/pureftpd/etc/pure-ftpd.conf