冷轩信 冷轩信

ubuntu 配置pure-ftpd-mysql 并开启匿名登录

in ubuntu 文章转载请注明来源!

1、安装Pure-FTPd
sudo apt-get install pure-ftpd-mysql mysql-server
2、添加用户和组
sudo groupadd -g 2001 ftpgroup sudo useradd -u 2001 -s /bin/false -d /dev/null -c "pure-ftpd user" -g ftpgroup ftpuser
3、Chroot设置
sudo sh -c "echo 'yes' > /etc/pure-ftpd/conf/ChrootEveryone"
4、手工创建用户目录
sudo sh -c "echo 'No' > /etc/pure-ftpd/conf/CreateHomeDir"
5、为Pure-FTPd创建MySQL数据库
mysql -u root -p
create database ftpusers;
创建数据库用户ftpadmin赋予权限
grant select,insert,update,delete,create,drop on ftpusers.* to 'ftpadmin'@'localhost' identified by 'admin888'; grant select,insert,update,delete,create,drop on ftpusers.* to 'ftpadmin'@'localhost.localdomain' identified by 'admin888'; flush privileges;
创建users表
use ftpusers
create table if not exists `users`( `user` varchar(16) not null default '', `password` varchar(32) not null default '', `uid` int(11) not null, `gid` int (11) not null, `dir` varchar(128) not null default '', `quotafiles` int(10) not null default '500', `quotasize` int(10) not null default '30', `ulbandwidth` int(10) not null default '80', `dlbandwidth` int(10) not null default '80', `ipaddress` varchar(15) not null default '*', `comment` tinytext, `status` enum('0','1') not null default '1', `ulratio` smallint(5) not null default '1', `dlratio` smallint(5) not null default '1', primary key (`user`), unique key `user` (`user`) )engine=myisam default charset=latin1; quit

6、配置Pure-FTPd的mysql.conf
sudo mv /etc/pure-ftpd/db/mysql.conf /etc/pure-ftpd/db/mysql.conf_orig sudo nano /etc/pure-ftpd/db/mysql.conf MySQLServer 127.0.0.1 MySQLSocket /var/run/mysqld/mysqld.sock MySQLUser ftpadmin MySQLPassword admin888 MySQLDatabase ftpusers MySQLCrypt md5 MySQLGetPW SELECT password FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetUID SELECT uid FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetGID SELECT gid FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetDir SELECT dir FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetQTAFS SELECT quotafiles FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetQTASZ SELECT quotasize FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetRatioUL SELECT ulratio FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGetRatioDL SELECT dlratio FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGETBandwidthUL SELECT ulbandwidth FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") MySQLGETBandwidthDL SELECT dlbandwidth FROM users WHERE user="\L" AND status="1" AND (ipaddress="*" OR ipaddress LIKE "\R") sudo chmod g=o= /etc/pure-ftpd/db/mysql.conf sudo /etc/init.d/pure-ftpd-mysql restart

7、安装web管理界面
到https://code.google.com/p/acelnmp/downloads/detail?name=ftp_v2.1.tar.gz&can=2&q=下载
解压缩
sudo tar zxvf ftp_v2.1.tar.gz
复制到web目录

修改配置文件,只修改下面显示的这几行,别的不用改
sudo nano /var/www/ftp/config.php $DBLogin = "ftpadmin"; // Username of MySQL user $DBPassword = "admin888"; // Password of MySQL user $DBDatabase = "ftpusers"; // Name of database $FTPAddress = "127.0.0.1:21"; // Domain name or ip-address of your ftp server $DEFUserID = "2001"; // nobody // Default user id of virtual ftp user. $DEFGroupID = "2001"; // guest // Default group is of virtual ftp user.

创建admin表
mysql -u root -p use ftpusers;
create table if not exists `admin`( `username` varchar(35) not null default '', `password` char(32) not null default '', primary key (`username`) )engine=myisam default charset=latin1;

插入管理帐号
insert into `admin` (`username`,`password`) values ('ftpadmin',MD5('admin888'));

登录你的服务器如 http://121.121.1211/ftp/添加ftp账号,uid 和gid注意要是2001,默认应该就是。

ubuntu开启pure-ftpd匿名登录
sudo groupadd -g 2002 ftp sudo useradd ftp -g ftp -d /var/ftp -s /sbin/nologin
sudo sh -c "echo 'no' > /etc/pure-ftpd/conf/NoAnonymous"
把文件内容改为no,no为允许匿名登录,yes为不允许

禁止匿名用户上传
sudo sh -c "echo 'yes' > /etc/pure-ftpd/conf/AnonymousCantUpload"
no 为允许上传,yes为不允许,
重启pureftpd生效
sudo /etc/init.d/pure-ftpd-mysql restart

部分转载自 http://bjiokn.blog.51cto.com/1021758/494845
http://wokelaoshi.blog.163.com/blog/static/16757831420106151441808/
http://os.51cto.com/art/201102/246394.htm

文章二维码

扫描二维码,在手机上阅读!

发表新评论

© 2018 由 Typecho 强力驱动.Theme by Yodu
PREVIOUS NEXT
雷姆
拉姆
0:00