FTP设置
配置ftp(系统自带)
QUOTE:
# ee /etc/inetd.conf
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l -h
QUOTE:
# ee /etc/rc.conf
inetd_enable="YES"
启动ftp
QUOTE:
# killall -HUP inetd
添加ftp用户组
QUOTE:
# pw groupadd ftpgroup -g 10001
添加ftp用户
QUOTE:
# adduser
Username:ftp
Full name:
Uid (Leave empty for default):1001
Login group [ftpuser]: ftpgroup
Login group is ftpgrou. Invite ftpuser into other groups? []:
Login class [default]:
Shell (sh csh tcsh zsh nologin) [sh]:
Home directory [/home/ftpuser]:/usr/www
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : ftpuser
Password : *****
Full Name :
Uid : 1001
Class :
Groups : ftpgroup
Home : /usr/www
Shell : /bin/sh
Locked : no
OK? (yes/no) : yes
adduser: INFO: Successfully added (ftpuser) to the user database.
Add another user? (yes/no): no
Goodbye!
禁止匿名用户登录
QUOTE:
# ee /etc/ftpusers
anonymous
@guest
设定用户使用目录
QUOTE:
# ee /etc/ftpchroot
ftpusr /usr/www
设置用户磁盘限额
QUOTE:
# ee /etc/rc.conf
enable_quotas="YES"
check_quotas="YES"
QUOTE:
# ee /etc/fstab
/dev/ad0s1f /usr ufs rw,userquota,groupquota 2 2
QUOTE:
# quotacheck -av
# repquota –a
# edquota –u ftpuser
/usr: kbytes in use: 0, limits (soft = 100000, hard = 100020) # soft是警告容量,hard是强制容量
QUOTE:
# edquota –t
/usr: block grace period: 1 minutes, file grace period: 1 minutes
QUOTE:
# quotaon -a
安装pure-ftpd(推荐)
QUOTE:
# pw groupadd ftpgroup -g 10001
# pw useradd ftp -u 10001 -g ftpgroup -s /sbin/nologin
# chown ftp:ftpgroup /usr/www
# cd /usr/ports/ftp/pure-ftpd
# ee Makefile
CONFIGURE_ARGS = --without-standalone # 为将来以守护进程模式运行准备(可选)
QUOTE:
# make install clean
选择MYSQL,PAM,PRIVSEP,PERUSERLIMITS,THROTTLING,BANNER,UPLOADSCRIPT,SENDFILE
建立pure-ftpd数据库
通过phpmyadmin执行
CREATE DATABASE pureftpd;
USE pureftpd;
CREATE TABLE `users` (
`User` varchar(16) NOT NULL default '',
`Password` varchar(32) binary NOT NULL default '',
`Uid` int(11) NOT NULL default '14',
`Gid` int(11) NOT NULL default '5',
`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',
`ipaccess` 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`)
) TYPE=MyISAM;
通过phpmyadmin新建一用户名为ftpadmin,密码adminpassword,并赋予其pureftpd数据库的Select,Insert,Update,Delete权限。
配置pure-ftp
QUOTE:
# cd /usr/local/etc
# cp pureftpd-mysql.conf.sample pureftpd-mysql.conf
# ee pureftpd-mysql.conf
# 具体选项请参考http://download.pureftpd.org/pub/pure-ftpd/doc/README
MYSQLServer localhost
MYSQLUser ftpadmin
MYSQLPassword adminpassword
MYSQLDatabase pureftpd
MYSQLCrypt crypt
MYSQLGetPW SELECT Password FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
# MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
# MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L" AND Status="1" AND (Ipaccess = "*" OR Ipaccess LIKE "\R")
如果以standalone(独立进程)方式运行,还需要编辑pure-ftpd的配置文件
QUOTE:
# cp pureftpd.conf.sample pure-ftpd.conf
# ee pure-ftpd.conf
让pure-ftpd随系统启动
如果以inetd(守护进程)方式运行
QUOTE:
# ee /etc/rc.conf
inetd_enable=”YES”
QUOTE:
# ee /etc/inetd.conf
# 详细启动参数请参考http://download.pureftpd.org/pub/pure-ftpd/doc/README
ftp stream tcp nowait root /usr/local/sbin/pure-ftpd pure-ftpd -A -b -c50 -C2 -D -E -fftp -H -i -I15 -lmysql:/usr/local/etc/pureftpd-mysql.conf -m4 -s -u100 -j -k99 -Z -4
如果以standalone(独立进程)方式运行
QUOTE:
# ee /usr/local/etc/rc.d/pure-ftpd.sh
#!/bin/sh
case "$1" in
start)
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
echo ‘pure-ftpd started!’
echo ‘’
;;
stop)
killall pure-ftpd
echo ‘pure-ftpd stopped!’
echo ‘’
;;
restart)
killall pure-ftpd
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
echo ‘pure-ftpd restarted!’
echo ‘’
;;
*)
echo ‘Usage: {start|stop|restart}’ >&2
exit 64
;;
esac
exit 0
QUOTE:
# chmod u+x /usr/local/etc/rc.d/pure-ftpd.sh
# ee /etc/rc.conf
pure-ftpd_enable=”YES”
安装配置pureftpdadmin
QUOTE:
# mount /cdrom
# cp –R /cdrom/pureftpdadmin /usr/www/pureftpdadmin
# ee /usr/www/pureftpdadmin/pureftp.config.php
$PUREFTP_CONFIG_FILE = '/usr/local/etc/pureftpd-mysql.conf';
$DefaultUser = "ftpadmin";
$DefaultPass = "adminpassword";
QUOTE:
# ee /usr/www/pureftpdadmin/goodies/Quota_Checker.php
$PUREFTP_CONFIG_FILE = '/usr/local/etc/pureftpd-mysql.conf';
QUOTE:
# chmod 755 /usr/local/sbin/pure-ftpwho
# chmod ug+s /usr/local/sbin/pure-ftpwho
设置pureftpdadmin安全
QUOTE:
# ee /usr/local/etc/apache22/httpd.conf
<Directory "/usr/www/pureftpdadmin">
deny from all
Options None
AllowOverride AuthConfig
Order deny,allow
</Directory>
QUOTE:
# ee /usr/www/pureftpdadmin/.htaccess
AuthType Basic
AuthUserFile /usr/local/ftpadmin.pwd
AuthName “操作前请登录”
require valid-user
satisfy any
QUOTE:
# htpasswd -bc /usr/local/ftpadmin.pwd ftpadmin adminpassword