Download - Instalacion de Proftpd y Mysql
INSTALACION DE PROFTPD Y MYSQL
Este documento describe cómo instalar un servidor de Proftpd que utiliza usuarios virtuales de una base de datos MySQL en vez de los usuarios del sistema real. Esto es mucho más rendimiento y permite tener miles de usuarios de FTP en una sola máquina. Para la administración de la base de datos MySQL puede usar las herramientas basadas en web como phpMyAdmin, que también se instalará en esta guía. PhpMyAdmin es una interfaz gráfica agradable que significa que usted no tiene que perder el tiempo con la línea de comandos.
INSTALAR MYSQL Y PHPMYADMINTodo esto se puede instalar con un solo comando:
root@dns:/home/jasmin# aptitude install mysql-server myaql-client papmyadmin apache2
Aca damos una contraseña para MySQL
Confirmamos la contraseña anteriormente ingresada:
INSTALAR PROFTPD CON SOPORTE EN MYSQL
Para ubuntu existe un paquete pre-configurado de proftpd-mysql. Lo Instalamos como independiente con:
root@dns:/home/jasmin#aptitude install proftpd-mod-mysql
Aceptamos la instalación, Lo configuramos como independiente o Standalone:
Ahora creamos un usuario y un grupo el cual sera asignado a cada uno de nuestros usuarios virtuales que podran tener acceso al servidor de archivos.
root@dns:/home/jasmin# groupadd -g 2001 ftpgrouproot@dns:/home/jasmin# useradd -u 2001 -g ftpgroup ftpuser
CREAR BASES DE DATOS CON MYSQL PARA PROFTPD
Ahora vamos a crear la base de datos “ftp” y un usuario llamado proftpd. Con el que mysql se conectara a la base de datos. Para ingresar a crear las bases de datos ingresamos:
root@dns:/home/jasmin# mysql –u root -p
Luego nos pedira un Password, esta es la contraseña que ingersamos en la instalacion de MySQL.
Despues entraremos a la linea de comandos de MySQL nos debería salir: mysql>
Podemos crear la base de datos por consola o disponemos de una herramienta grafica llamada phpmyadmin que nos facilitara en gran medida la creación de las Bases de Datos en este tutorial voy a explicar las dos.
CREATE DATABASE ftp; “creamos nuestra base de datos”
mysql> CREATE DATABASE ftp;Query OK, 1 row affected (0, 02 sec)
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost' IDENTIFIED BY 'password'; en “password “ le damos la contraseña de MySQL
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost'IDENTIFIED BY 'redes'; Query OK, 0 rows affected (0,03 sec)
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost.localdomain' IDENTIFIED BY 'password'; en “password “ le damos la contraseña de MySQL
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost'IDENTIFIED BY 'redes'; Query OK, 0 rows affected (0,04 sec)
FLUSH PRIVILEGES;
mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0,00 sec)
En phpmyadmin:
En la pestaña privilegios le damos los privilegios que mostré anteriormente por consola.
Ahora vamos a crear la base de datos “ftp” y un usuario llamado proftpd. Con el que mysql se conectara a la base de datos.
USE ftp;
mysql> USE ftp;Database changed
Creamos dos tablas con los siguientes parametros:
CREATE TABLE ftpgroup ( groupname varchar(16) NOT NULL default '', gid smallint(6) NOT NULL default '5500', members varchar(16) NOT NULL default '', KEY groupname (groupname) ) TYPE=MyISAM COMMENT='ProFTP group table';
mysql> CREATE TABLE ftpgroup ( -> groupname varchar(16) NOT NULL default '', -> gid smallint(6) NOT NULL default '5500', -> members varchar(16) NOT NULL default '', -> KEY groupname (groupname) -> ) TYPE=MyISAM COMMENT='ProFTP group table'; Query OK, 0 rows affected, 1 warning (0,00 sec)
En phpmyadmin:
Creamos los Campos anteriores:
CREATE TABLE 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 '5500', gid smallint(6) NOT NULL default '5500', homedir varchar(255) NOT NULL default '', 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) ) TYPE=MyISAM COMMENT='ProFTP user table';
mysql> CREATE TABLE 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 '5500', -> gid smallint(6) NOT NULL default '5500', -> homedir varchar(255) NOT NULL default '', -> 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) -> ) TYPE=MyISAM COMMENT='ProFTP user table';Query OK, 0 rows affected, 1 warning (0,01 sec)
En phpmyadmin:
Con los parametros:
Salimos de la linea de comandos:
mysql> quit;Bye
CONFIGURAR PROFTPD
Primero modificamos el archivo modules.conf
root@dns:/home/jasmin# nano /etc/proftpd/modules.conf
Descomentamos las siguientes lineas:
Despues modificamos el archivo proftpd.conf
root@dns:/home/jasmin# nano /etc/proftpd/proftpd.conf
Comentamos, des comentamos y modificamos las siguientes líneas:
UseIPv6 off ServerName "fpt" ServerType standalone DeferWelcome off
DefaultRoot ~
User proftpd Group nogroup
Include /etc/proftpd/sql.conf
User ftp Group nogroup
DirFakeUser on ftp DirFakeGroup on ftp <Directory /var/www/> <Limit WRITE>
DenyAll </Limit> </Directory>
Ahora configuramos el archivo sql.conf
root@dns:/home/jasmin# nano /etc/proftpd/sql.confY agregamos la siguientes lineas:
DefaultRoot ~SQLBackend mysql
# The passwords in MySQL are encrypted using CRYPTSQLAuthTypes Plaintext CryptSQLAuthenticate users groups
# used to connect to the database# databasename@host database_user user_password
SQLConnectInfo [email protected] proftpd redes
# Here we tell ProFTPd the names of the database columns in the "usertable"# we want it to interact with. Match the names with those in the db
SQLUserInfo ftpuser userid passwd uid gid homedir shell
# Here we tell ProFTPd the names of the database columns in the "usertable"# we want it to interact with. Match the names with those in the db
SQLUserInfo ftpuser userid passwd uid gid homedir shell
# Here we tell ProFTPd the names of the database columns in the "grouptable"# we want it to interact with. Again the names match with those in the db
SQLGroupInfo ftpgroup groupname gid members
# set min UID and GID - otherwise these are 999 each
SQLMinID 500
# create a user's home directory on demand if it doesn't existCreateHome on
# Update count every time user logs in
SQLLog PASS updatecountSQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHEREuserid='%u'" ftpuser
# Update modified everytime user uploads or deletes a file
SQLLog STOR,DELE modifiedSQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
RootLogin offRequireValidShell off
</IfModule>
Nota: Todas estas lineas deben quedar dentro de la sentencia </IfModule> ya que el final del archivo antes de ingresar estos nuevos valores al final se encuentra </IfModule>, entonces debemos ingresar los datos tal que dejemos </IfModule> al final del archivo ya modificado o si no nuestra configuracion sera nula.
Reiniciamos nuestro servicio para que pueda aplicar todos los cambios hechos.
root@dns:/home/jasmin# /etc/init.d/proftpd restart
Ingresamos nuevamente a la base de datos de MySQL:
root@dns:/home/jasmin# mysql –u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 46Server version: 5.1.37-1ubuntu5 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Ingresamos a la base de datos de ftp:
mysql> USE ftp;
mysql> USE ftp;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A
Database changedmysql> INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', 2001, -> 'ftpuser');Query OK, 1 row affected (0,17 sec)
mysql> INSERT INTO `ftpuser` (`id`, `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, -> `count`, `accessed`, `modified`) VALUES (1, 'jasmin', 'redes’, '>2001, 2001, 'home/jasmin', -> '/sbin/nologin', 0, '', '');Query OK, 1 row affected, 2 warnings (0,00 sec)
En phpmyadmin:
En la tabla ftpgroup en la pestaña ingresar, escribimos los valores anteriormente explicados
En la tabla ftpuser en la pestaña ingresar, escribimos nuestros valores anteriormente explicados.
Salimos de la línea de comandos:
mysql> quit;Bye
Comprobamos que el directorio jasmin este en el grupo ftp y que el usuario sea ftpuser:
root@dns:/home/jasmin# ls –l /home
total 8drwxr-xr-x 2 ftp nogroup 4096 2010-02-02 11:46 ftpdrwxr-xr-x 33 jasmin jasmin 4096 2010-02-02 19:03 jasmin