Документация по ОС FreeBSD Четверг, 25.04.2024, 02:15
Приветствую Вас Гость | RSS
Меню сайта

Категории каталога
Apache [58]
DNS [25]
FTP [27]
Mail [74]
Samba [24]
Squid [46]
SSH [23]
VPN [35]
РРР [20]
Net [173]

Главная » Статьи » Сеть » FTP

Администрирование Pureftpd с помощью вэб интерфейса Usermanager [2008]
PureftpD и UserManager

Создание FTP сервера, которым можно управлять с помощью вэб-интерфейса (UserManager)
UserManager даёт возможность администратору сервера легкого
управления пользователями ftp. Их создание , удаление , назначение папок
в которых они будут работать.
Используемое ПО:
uname -rp
6.4-RELEASE i386
pkg_info -Ix apac ftp sql php perl pcre User
UserManager-2.1 Easily create, change, or delete virtual PureFTPd users
apache-2.0.63_2 Version 2.0.x of Apache web server with prefork MPM.
mysql-client-6.0.7 Multithreaded SQL database (client)
mysql-server-6.0.7 Multithreaded SQL database (server)
pcre-7.8 Perl Compatible Regular Expressions library
perl-5.8.8_1 Practical Extraction and Report Language
php5-5.2.7 PHP Scripting Language
php5-bz2-5.2.7 The bz2 shared extension for php
php5-ctype-5.2.7 The ctype shared extension for php
php5-gd-5.2.7 The gd shared extension for php
php5-mbstring-5.2.7 The mbstring shared extension for php
php5-mcrypt-5.2.7 The mcrypt shared extension for php
php5-mysql-5.2.7 The mysql shared extension for php
php5-openssl-5.2.7 The openssl shared extension for php
php5-posix-5.2.7 The posix shared extension for php
php5-session-5.2.7 The session shared extension for php
php5-simplexml-5.2.7 The simplexml shared extension for php
php5-spl-5.2.7 The spl shared extension for php
php5-zlib-5.2.7 The zlib shared extension for php
phpMyAdmin-3.1.0 A set of PHP-scripts to manage MySQL over the web
pure-ftpd-1.0.21_2 A small, easy to set up, fast and very secure FTP server

Это тот необходимый минимум который мне понадобился.
Сам pureftpd был собран со следующими опциями
#pwd
/usr/ports/ftp/pure-ftpd
#make showconfig
===> The following configuration options are available for pure-ftpd-1.0.21_2:
 LDAP=off "Support for users in LDAP directories"
 MYSQL=on "Support for users in MySQL database"
 PAM=on "Support for PAM authentication"
 PGSQL=off "Support for users in PostgreSQL database"
 PRIVSEP=off "Enable privilege separation"
 PERUSERLIMITS=on "Per-user concurrency limits"
 THROTTLING=on "Bandwidth throttling"
 BANNER=on "Show pure-ftpd welcome upon session start"
 UPLOADSCRIPT=on "Support uploadscript daemon"
 UTF8=on "Support for charset conversion (expreimental)"
 SENDFILE=on "Support for the sendfile syscall"
===> Use 'make config' to modify these settings
#

Установка вэб-интрефейса к PureftpD (UserManager)
#pwd
/usr/ports/www/usermanager
#make install clean

mv /usr/local/www/data/UserManager/ /usr/local/www/

Алиас для Апача
# pwd
/usr/local/etc/apache2/Includes
#cat usermanager.conf
Alias /ftpadm "/usr/local/www/UserManager/"

<Directory "/usr/local/www/UserManager">
# Options Indexes
 Options Indexes FollowSymlinks MultiViews
 AllowOverride AuthConfig
 DirectoryIndex index.php
 Order deny,allow
 Allow from all
</Directory>

Так же необходимо проверить что в php.ini присутствует
short_open_tag = On

Далее настройка проста, открываем броузером
http://192.168.10.5/ftpadm/install.php

И пошагово выполняем то о чём нас спрашивают:

This configuration script has carried out a few checks 
to see if everything is ready to start the configuration.
 
Checking if config.php exists OK! 
Checking if config.php is writable OK! 
Checking if PHP Extension MYSQL is enabled OK! 
Checking if PHP Extension PCRE is enabled OK! 
Checking if PHP Extension POSIX is enabled OK! 
Checking if PHP Extension SESSION is enabled OK!

2ой шаг - утсановка базы данных которая будет использоватья вэб
интерфейсом и демоном pureftpd
New installation,
create a new database.

Далее возникла небольшая проблема...
Checking connection to MySQL server OK! 
Create user FTP OK! 
Create database ftpusers OK! 
Create table admin Failed! 
Create table users Failed!

При первой попытке установить всё легким путем у меня ничего хорошего не получилось.
Было решено удалить БД ftpusers;
И совсем немножко подправить файл-дамп бд. Т.к. не получалось
его импортнуть через вэб интерфейс,необходимо было его залить консольным методом.
качаем файлик который будет создавать бд , пользователя и пароль на нашу базу
fetch ftp://ftp.lissyara.su/users/morty/pftpcfg/db.sql

db.sql - Создаёт пользователя и права для базы. (База ftpusers, пользователь - ftp,
пароль - ftp_pass)
Эти данные нам понадобяться когда мы вернемся к установке "через вэб".
mysql -uroot -pparol_roota < db.sql

UserManager идет с файликом дампом бд который расположен тут ../extra/script.mysql
но так как мы немного отклонились от стандартного пути, то далее качаем дамп
fetch ftp://ftp.lissyara.su/users/morty/pftpcfg/script.mysql

Он практически ничем не отличается от родного.
А также сразу выкачиваем Russian Language Pack для вэб интерфейса
fetch ftp://ftp.lissyara.su/users/morty/pftpcfg/russian.php

cp russian.php /usr/local/www/UserManager/language/russian.php

Возвращаемся к установке с вэб страницы, вводим данные пользователя ,бд и его пароль.
На данном этапе будут генериться конфиги для pure-ftpd.conf и pureftpd-mysql.conf.
Вприниципе можно все оставить как есть, только поменять язык по умолчанию на русский
и вписать необходимый FTP Address. А также я еще выбрал
Quota support
Ratio support
Но еще не тестировал эти вещи.
Далее сохраняем настройки — нажимаем Save, настройки будут сохранены в файле
/usr/local/www/UserManager/config.php

Следующий этап - это создание административного аккаунта для доступа на вэб панель.
Я поставил на Administrator пароль 12345,
при необходимости его всегда можно изменить
например через PhPMyAdmin (база ftpusers, таблица admin).
После этого нам предлагают скопипастить конфиги для purefptd. Чем и займемся:
#cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf
#echo \
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf >> \ 
/usr/local/etc/pure-ftpd.conf

и содержимое файла /usr/local/etc/pureftpd-mysql.conf

############################################################################
# #
# PureFTPd MySQL configuration file. #
# Generated by the installation wizard for the 'User manager for PureFTPd' #
# See http://machiel.generaal.net for more info #
# or read the README.MySQL for explanations of the syntax. #
# #
############################################################################

# Optional : MySQL server name or IP. Don't define this for unix sockets.

MYSQLServer 127.0.0.1

# Optional : MySQL port. Don't define this if a local unix socket is used.

# MYSQLPort 3306

# Optional : define the location of mysql.sock if the server runs on this host.

MYSQLSocket /tmp/mysql.sock

# Mandatory : user to bind the server as.

MYSQLUser ftp

# Mandatory : user password. You must have a password.

MYSQLPassword ftp_pass

# Mandatory : database to open.

MYSQLDatabase ftpusers

# Mandatory : how passwords are stored
# Valid values are : "cleartext", "crypt", "md5" and "password"
# ("password" = MySQL password() function)
# You can also use "any" to try "crypt", "md5" *and* "password"

MYSQLCrypt md5

# In the following directives, parts of the strings are replaced at
# run-time before performing queries :
#
# \L is replaced by the login of the user trying to authenticate.
# \I is replaced by the IP address the user connected to.
# \P is replaced by the port number the user connected to.
# \R is replaced by the IP address the user connected from.
# \D is replaced by the remote IP address, as a long decimal number.
#
# Very complex queries can be performed using these substitution strings,
# especially for virtual hosting.

# Query to execute in order to fetch the password

MYSQLGetPW SELECT Password FROM users WHERE User="\L" AND Status="1" 
AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Query to execute in order to fetch the system user name or uid
MYSQLGetUID SELECT Uid FROM users WHERE User="\L" AND Status="1"
 AND (Ipaddress = "*" OR Ipaddress LIKE "\R")
# Optional : default UID - if set this overrides MYSQLGetUID
#MYSQLDefaultUID 1000

# Query to execute in order to fetch the system user group or gid
MYSQLGetGID SELECT Gid FROM users WHERE User="\L" AND Status="1"
AND (Ipaddress = "*" OR Ipaddress LIKE "\R")

# Optional : default GID - if set this overrides MYSQLGetGID
#MYSQLDefaultGID 1000

# Query to execute in order to fetch the home directory

MYSQLGetDir SELECT Dir FROM users WHERE User="\L" AND Status="1"
AND (Ipaddress = "*" OR Ipaddress LIKE "\R")

# Optional : query to get the maximal number of files
# Pure-FTPd must have been compiled with virtual quotas support.

MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"
 AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")

# Optional : query to get the maximal disk usage (virtual quotas)
# The number should be in Megabytes.
# Pure-FTPd must have been compiled with virtual quotas support.

MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L" 
AND Status="1" AND (Ipaddress = "*" OR Ipaddress LIKE "\R")

# Optional : ratios. The server has to be compiled with ratio support.

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")

# Optional : bandwidth throttling.
# The server has to be compiled with throttling support.
# Values are in KB/s .

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")

# Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS :
# 1) You know what you are doing.
# 2) Real and virtual users match.

# MySQLForceTildeExpansion 1

# If you upgraded your tables to transactionnal tables (Gemini,
# BerkeleyDB, Innobase...), you can enable SQL transactions to
# avoid races. Leave this commented if you are using the
# traditionnal MyIsam databases or old (< 3.23.x) MySQL versions.

# MySQLTransactions On

Осталось прописать в /etc/rc.conf
pureftpd_enable=YES
mysql_enable=YES
apache2_enable=YES

не забываем завести в системе пользователя ftp
я завёл через adduser как обычного пользователя, только с рандомной
генерацией пароля.Насколько это правильно или нет - судите сами ;-)
Запускаем
/usr/local/etc/rc.d/pure-ftpd start
Starting pureftpd.
Running: /usr/local/sbin/pure-ftpd -A -c50 -B -C8 -D -fftp -H -I15 -L2000:8
 -m4 -s -U133:022 -u100 -k99 -Z -lmysql:/usr/local/etc/pureftpd-mysql.conf

Всё. Теперь можно начинать пользоваться, открываем броузером
http://192.168.10.5/ftpadm/
Вводим Administrator / 12345
Далее панель админа
-------------------------------------------------------------------------------------------------------------------
Похоже где-то накосячил с паролями  для Administrator
не хотело пускать
Удаляем то что касалось старых записей для админа и заводим новую

mysql> delete from admin where Username='Administrator';
mysql> insert into admin(Username, Password) values ('Admin',md5('12345'));

PS: Есть у этого вэб интерфейса 1 минус - не отображаються пути к дирикториям,
немного не удобно когда пытаешься настроить нового пользователя и выбрать где
он будет chroot'иться. Хотя может и я где-то , что-то не увидел и оно так работает.

Первоисточник:
http://machiel.generaal.net/index.php?subject=pureftpd&language=eng
http://machiel.generaal.net/index.php?subject=user_manager_pureftpd



Источник: http://www.lissyara.su/?id=1823
Категория: FTP | Добавил: oleg (14.12.2008) | Автор: Morty
Просмотров: 1888 | Комментарии: 1 | Рейтинг: 0.0/0 |
Всего комментариев: 1
1 =MEFISTOFEL=  
0
Там триугольник есть справа cool

Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Форма входа

Beastie

Друзья сайта

Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
links

Copyright MyCorp © 2024